diff --git a/lib/bashly/commands/add.rb b/lib/bashly/commands/add.rb index 840a799b..c65dd527 100644 --- a/lib/bashly/commands/add.rb +++ b/lib/bashly/commands/add.rb @@ -3,7 +3,7 @@ module Commands class Add < Base help 'Add extra features and customization to your script' - usage 'bashly add [--source NAME] LIBRARY [ARGS...] [--force]' + usage 'bashly add [--source NAME] LIBRARY [ARGS...] [--force --quiet]' usage 'bashly add [--source NAME] --list' usage 'bashly add (-h|--help)' @@ -17,6 +17,7 @@ class Add < Base USAGE option '-f --force', 'Overwrite existing files' option '-l --list', 'Show available libraries' + option '-q --quiet', 'Do not show post-install messages' attr_reader :skip_src_check @@ -70,7 +71,9 @@ def add_library_files(library) end message = library.post_install_message - say "\n#{message}" if message && files_created.positive? + return if !message || files_created.zero? || args['--quiet'] + + say "\n#{message}" end def safe_write(path, content) diff --git a/spec/approvals/cli/add/colors-quiet b/spec/approvals/cli/add/colors-quiet new file mode 100644 index 00000000..affaa155 --- /dev/null +++ b/spec/approvals/cli/add/colors-quiet @@ -0,0 +1 @@ +created spec/tmp/src/lib/colors.sh diff --git a/spec/approvals/cli/add/help b/spec/approvals/cli/add/help index fef67727..d8370b9b 100644 --- a/spec/approvals/cli/add/help +++ b/spec/approvals/cli/add/help @@ -1,7 +1,7 @@ Add extra features and customization to your script Usage: - bashly add [--source NAME] LIBRARY [ARGS...] [--force] + bashly add [--source NAME] LIBRARY [ARGS...] [--force --quiet] bashly add [--source NAME] --list bashly add (-h|--help) @@ -20,5 +20,8 @@ Options: -l --list Show available libraries + -q --quiet + Do not show post-install messages + -h --help Show this help diff --git a/spec/approvals/cli/add/usage b/spec/approvals/cli/add/usage index 9791e458..d60e2633 100644 --- a/spec/approvals/cli/add/usage +++ b/spec/approvals/cli/add/usage @@ -1,4 +1,4 @@ Usage: - bashly add [--source NAME] LIBRARY [ARGS...] [--force] + bashly add [--source NAME] LIBRARY [ARGS...] [--force --quiet] bashly add [--source NAME] --list bashly add (-h|--help) diff --git a/spec/bashly/commands/add_spec.rb b/spec/bashly/commands/add_spec.rb index d2d6da3c..28a27e58 100644 --- a/spec/bashly/commands/add_spec.rb +++ b/spec/bashly/commands/add_spec.rb @@ -47,6 +47,17 @@ end end + describe 'add colors --quiet' do + let(:lib_file) { "#{source_dir}/lib/colors.sh" } + + before { reset_tmp_dir create_src: true } + + it 'does not show the post-install message' do + expect { subject.execute %w[add colors --quiet] }.to output_approval('cli/add/colors-quiet') + expect(File).to exist(lib_file) + end + end + describe 'add completions' do before { reset_tmp_dir init: true }