Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

outdated - Exit 2 when there are packages out of date (enhanced exit code) #1602

Closed
proudcanadianeh opened this issue Jun 25, 2018 · 12 comments

Comments

@proudcanadianeh
Copy link

proudcanadianeh commented Jun 25, 2018

Would absolutely love different exit codes for choco outdated for if it does or does not find packages that need to be updated.

Would make it very easy to script a check that way.


Edited by Rob to add the following:

Release Notes

  • Exit of 0 indicates all up to date
  • Exit of 2 indicates out of date packages
  • Exit of 1 or -1 (or really anything else) would indicate an error

Related to #1758

@bcurran3
Copy link

@proudcanadianeh - consider giving some examples of your preferred output for the Chocolatey Team to consider. Help steer them towards what you want. :)

@proudcanadianeh
Copy link
Author

For my purposes, have an exit code of 0 if everything is up to date, 5 if stuff is out of date, 10 if there is an error checking for updates.

@cs96and
Copy link

cs96and commented Sep 20, 2018

I would like some exit status from choco outdated too. I have written a PyQt system tray app that runs "choco outdated" one per day and notifies the user if there are any updates available...
https://bitbucket.org/cs96and/choco-toast/src

The problem I have is that the python script cannot tell if an error occurs (e.g. if my internet connection is down), and reports all the error messages as available updates. This is exacerbated by two additional problems...

  1. All errors are reported to stdout instead of stderr, even if --fail-on-stderr option is given.
  2. Each error message is followed by the package details, as if that package is actually outdated. E.g....
choco outdated --limit-output --nocolor --ignore-pinned --no-progress --fail-on-stderr -s https://127.0.0.1/doesnt/exist
[NuGet] An error occurred while loading packages from 'https://127.0.0.1/doesnt/exist': Unable to connect to the remote server
7zip|18.5.0.20180730|18.5.0.20180730|false
[NuGet] An error occurred while loading packages from 'https://127.0.0.1/doesnt/exist': Unable to connect to the remote server
7zip.install|18.5.0.20180730|18.5.0.20180730|false

@ferventcoder
Copy link
Member

@cs96and I think you are missing an additional switch --ignore-unfound.

@ferventcoder
Copy link
Member

@cs96and Some of that could be that [NuGet] portions of the log still write to stdout instead of stderr and possibly don't affect the fail on stderr option. Probably best for you to file new issues for those two things so they don't get lost. Thanks in advance!

@ferventcoder
Copy link
Member

@proudcanadianeh this is a great idea! I think we'll want to approach this for next release. Error would be exit code 1 though.

@ferventcoder ferventcoder changed the title choco outdated exit codes outdated - Use exit codes to determine update status Sep 26, 2018
@cs96and
Copy link

cs96and commented Sep 26, 2018

Using --ignore-unfound gets rid of problem 2. I'll file a separate bug report about problem 1.

@ferventcoder ferventcoder self-assigned this Mar 12, 2019
ferventcoder added a commit that referenced this issue Mar 13, 2019
When items are outdated, the exit should indicate that it is not all
good to go as there is possible work to do. A zero exit code should
only be used if choco outdated does not return any results.

- Exit of 0 indicates all up to date
- Exit of 2 indicates out of date packages
- Exit of 1 or -1 would indicate an error
ferventcoder added a commit that referenced this issue Mar 13, 2019
* stable:
  (maint) Corrected whitespace
  (GH-1689) Delete packaging scripts before upgrade
  (doc) fix grammar in scripting guidelines
  (doc) add don't use nupkg to scripting guidelines
  (maint) fix typo
  (GH-1602) exit 2 on items outdated
  (doc) add step for rebasing prior to merging
  (GH-1614) Quote source name if includes pipe
@ferventcoder
Copy link
Member

This will be released with 0.10.12. Thanks for the patience on this one.

@ferventcoder ferventcoder changed the title outdated - Use exit codes to determine update status outdated - Exit 2 when there are packages out of date Mar 14, 2019
@ferventcoder ferventcoder changed the title outdated - Exit 2 when there are packages out of date outdated - Exit 2 when there are packages out of date (enhanced exit code) Mar 14, 2019
ferventcoder added a commit that referenced this issue Mar 14, 2019
In #1602 and #1724, enhanced exit codes were added to provide more
intentional exit codes that determine the state of what happened during
the run. This would allow simply seeing a 0 from outdated and knowing
that all packages are up to date, or seeing a 2 and knowing that
packages need updated. This allows for better scripting based on exit
codes.

However, there are some existing integrations that might be broken on
taking on a newer version of Chocolatey if the enhanced exit codes are
not being looked for yet. To allow compatibility to older systems, add
a feature switch that can be disabled to provide the older behavior of
0 or 1 exit codes.
@xtimon
Copy link

xtimon commented Mar 20, 2019

@xtimon
Copy link

xtimon commented Mar 20, 2019

ERROR_FILE_NOT_FOUND

2 (0x2)

The system cannot find the file specified.

@xtimon
Copy link

xtimon commented Mar 21, 2019

How to avoid the invalid exit code?

@xtimon
Copy link

xtimon commented Mar 21, 2019

choco feature disable --name="'useEnhancedExitCodes'"

@gep13 gep13 removed the 4 - Done label Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants