(#1759) Add enhanced exit codes for multiple commands
Description Of Changes
This adds enhanced exit codes to the apikey, config, feature, pin, source and upgrade commands. Specifically, it adds exit code 2 for when there is nothing to do. All of these commands except upgrade have a NOCHANGEMESSAGE that is output, this sets exit code 2 if the conditions are met for that message to be logged, enhanced exit codes are enabled, and there is not another preexisting exit code set other than zero.
The upgrade command required returning more information from a method to allow checking if no packages were outdated. The check is done by checking that there are no successes or failures.
Motivation and Context
Adding support for enhanced exit codes in more commands is useful for users that script choco, as it gives more information in a easily usable format of an exit code.
I did not try adding enhanced exit codes to push (#1763) as I don't think there is a way yet to check if the package already exists on the remote source. It would probably should be a separate PR, and perhaps a series of PRs even. (Edit, #494 would have to be completed first)
Testing
.\choco.exe feature disable -n useEnhancedExitCodes
.\choco.exe apikey add --source="https://does.not.exist" --key="1234abcd"
.\choco.exe apikey add --source="https://does.not.exist" --key="1234abcd" # Should return zero
WIP - COMPLETE
.\choco.exe feature enable -n useEnhancedExitCodes
.\choco.exe apikey add --source="https://does.not.exist" --key="1234abcd" # Should return two
Change Types Made
- [ ] Bug fix (non-breaking change)
- [x] Feature / Enhancement (non-breaking change)
- [ ] Breaking change (fix or feature that could cause existing functionality to change)
Related Issue
Fixes #1759 (apikey) Fixes #1760 (config) Fixes #1761 (feature) Fixes #1762 (pin) Fixes #1764 (source) Fixes #2200 (upgrade)
Change Checklist
- [x] Requires a change to the documentation
- [x] Documentation has been updated
- [ ] Tests to cover my changes, have been added
- [ ] All new and existing tests passed.
- N/A PowerShell v2 compatibility checked.
Coverage decreased (-0.2%) to 28.412% when pulling 57a7808d1f124f5a4c2e0b56cdfc1cf60e8a82c4 on TheCakeIsNaOH:apikey-exit-code into 6f3fc1550148bb3ce8d75f6db2d3ca1528cf4587 on chocolatey:develop.
@TheCakeIsNaOH I have taken the liberty to do some fix-ups on this PR. I am also going to get some tests written to test out some of these changes, and then look to get this merged next week.
Thanks for all the work that you have put into this!
@TheCakeIsNaOH thank you very much for getting all of these exit codes added! Really appreciate it!