chocolatey / choco

Chocolatey - the package manager for Windows
https://chocolatey.org
Other
10.04k stars 890 forks source link

Add a command-line option for quiet output #3457

Open pawelszramowski opened 1 month ago

pawelszramowski commented 1 month ago

Checklist

Is Your Feature Request Related To A Problem? Please describe.

Choco prints a lot of unnecessary information with no simple way to suppress it. Consider this output from choco install ninja --version 1.10.2 --yes --allow-downgrade:

Chocolatey v2.2.2
Installing the following packages:
ninja
By installing, you accept licenses for the packages.
ninja v1.10.2 already installed.
 Use --force to reinstall, specify a version to install, or try upgrade.

Chocolatey installed 0/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Warnings:
 - ninja - ninja v1.10.2 already installed.
 Use --force to reinstall, specify a version to install, or try upgrade.

When the command is run manually, it may make sense to show this. However, when it's run from a script, really none of these messages need to be shown and they just pollute the output.

Describe The Solution. Why is it needed?

--quiet command-line option should be added. The option should cause only errors to be printed. If the caller wanted to suppress warnings too, they should redirect the standard error stream to null (but see the issue listed as related).

Option --limit-output is not a solution here, because it suppresses the errors too.

Additional Context

In Python package manager pip, --quiet is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels). It's the opposite of --verbose.

Related Issues