Skip to content
New issue

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

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

Already on GitHub? # to your account

search/list/info - Exit 2 when no results are returned (enhanced exit code) #1724

Closed
rjjacobs200 opened this issue Feb 9, 2019 · 2 comments

Comments

@rjjacobs200
Copy link

rjjacobs200 commented Feb 9, 2019

Queries of packages using "list" or "info" which return no results could return an error code of 1 (or something other than 0). Managers like scoop do this, and it makes scripting or integration into other systems much easier.


Related to #1758

@ferventcoder ferventcoder self-assigned this Mar 11, 2019
@ferventcoder ferventcoder added this to the 0.10.12 milestone Mar 11, 2019
@ferventcoder ferventcoder changed the title Different error codes for "list" or "info" queries with no results search/list/info - exit 1 when no results are returned Mar 11, 2019
ferventcoder added a commit that referenced this issue Mar 11, 2019
Instead of exiting with 0 if no results are found, exit with something
different to indicate that nothing was found. 0 would indicate a
success that there was results, where 1 would indicate something isn't
quite right if there was an expectation of finding something.
@ferventcoder
Copy link
Member

@rjjacobs200 I agree that there should be a different exit code if nothing is found.

This was added at 47cbdd8 and will be released in 0.10.12.

ferventcoder added a commit that referenced this issue Mar 12, 2019
* stable:
  (GH-1562) Fix: --version includes warnings/errors
  (GH-1724) search - exit 1 on no results
  (GH-1614) Fix: quote if pipe found in string
@ferventcoder ferventcoder changed the title search/list/info - exit 1 when no results are returned search/list/info - exit 2 when no results are returned Mar 14, 2019
@ferventcoder
Copy link
Member

Moved this to a 2 so that it is deterministic that is what caused the exit. Added documentation about exit codes that will be in choco search -?

@ferventcoder ferventcoder changed the title search/list/info - exit 2 when no results are returned search/list/info - Exit 2 when no results are returned Mar 14, 2019
@ferventcoder ferventcoder changed the title search/list/info - Exit 2 when no results are returned search/list/info - Exit 2 when no results are returned (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.
ferventcoder added a commit that referenced this issue Mar 14, 2019
Preserve 1 and -1 for errors. No results should have something more
deterministic, and 2 would provide that.
ferventcoder added a commit that referenced this issue Mar 15, 2019
* stable:
  (doc) add exit codes to gen doc headings
  (doc) update generated docs
  (version) 0.10.12
  (doc) fix grammar
  (GH-1038) remove note on off recommendation
  (GH-1746) allow shutting off validation warnings
  (doc) update release notes for licensed extension
  (maint) whitespace
  (doc) update release notes
  (maint) formatting
  (GH-1758)(doc) provide exit code docs
  (doc) info - add usage / examples
  (doc) outdated - note ignore unfound
  (doc) scripting - point to scripting reference
  (doc) scripting - how to get exit code w/powershell
  (GH-1724) search - exit 2 on no results
  (GH-1758) control enhanced exit codes w/feature
  (doc) update release notes for 0.10.12 release
  (doc) update older release notes
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants