Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --quiet to bashly add command #612

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading