anishathalye / dotbot

A tool that bootstraps your dotfiles ⚡️
MIT License
6.91k stars 288 forks source link

Shell commands without description cause the command to be shown even if `quiet: true` #265

Closed chalkygames123 closed 1 year ago

chalkygames123 commented 3 years ago

Hi, thank you for maintaining such a great tool.

Currently, Dotbot shows the command if its quiet option is set to true but no description. Is it intended behavior?

For example, with this config, Dotbot will only show the command's stdout:

- shell:
    - command: echo 'Hello, world!'
      description: ''
      quiet: true
      stdout: true
% ./install

Hello, world!
All commands have been executed

==> All tasks executed successfully

but with this one, it will also show the command itself:

- shell:
    - command: echo 'Hello, world!'
      quiet: true
      stdout: true
% ./install
echo 'Hello, world!'
Hello, world!
All commands have been executed

==> All tasks executed successfully
anishathalye commented 3 years ago

Note that in the first case, the description is being printed, it's just the empty string, so that's why there's an extra newline there.

I think we can change the behavior in this case. The docs currently say "Show only the description but not the command in log output", but don't exactly specify what should happen if quiet is true but no description is given. Would it make more sense to hide the command when no description is given and quiet is set to true?

chalkygames123 commented 3 years ago

Yeah, I guess it looks like more predictable behavior and would fit my use case. Let's say we are setting up system settings (e.g., using macOS defaults command). Sometimes it will need re-login to take effect, so we want to remind ourselves of it just to be sure.

For example:

- shell:
    - defaults write -g InitialKeyRepeat -int 10
    - defaults write -g KeyRepeat -int 1
    - command: |-
        echo 'NOTE: Some of the changes will take effect the next time you log in.'
      quiet: true
      stdout: true
anishathalye commented 1 year ago

Fixed in https://github.com/anishathalye/dotbot/pull/327.