Skip to content

Commit

Permalink
Merge pull request #612 from DannyBen/add/bashly-add-quiet-flag
Browse files Browse the repository at this point in the history
Add `--quiet` to `bashly add` command
  • Loading branch information
DannyBen authored Jan 21, 2025
2 parents 43e0244 + ca0a546 commit 5567311
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/bashly/commands/add.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)'

Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions spec/approvals/cli/add/colors-quiet
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
created spec/tmp/src/lib/colors.sh
5 changes: 4 additions & 1 deletion spec/approvals/cli/add/help
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -20,5 +20,8 @@ Options:
-l --list
Show available libraries

-q --quiet
Do not show post-install messages

-h --help
Show this help
2 changes: 1 addition & 1 deletion spec/approvals/cli/add/usage
Original file line number Diff line number Diff line change
@@ -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)
11 changes: 11 additions & 0 deletions spec/bashly/commands/add_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down

0 comments on commit 5567311

Please sign in to comment.