Skip to content

Commit 0aa53db

Browse files
committed
- Add --quiet to bashly generate
1 parent 4bbb17b commit 0aa53db

File tree

5 files changed

+14
-24
lines changed

5 files changed

+14
-24
lines changed

Runfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
require "runfile-tasks"
22
require "byebug"
3+
require "colsole"
34
require_relative 'lib/bashly'
45
require_relative 'helpers/example'
6+
include Colsole
57

68
title "Bashly Developer Toolbelt"
79
summary "Runfile tasks for building the Bashly gem"

lib/bashly/commands/generate.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Generate < Base
88

99
option "-f --force", "Overwrite existing files"
1010
option "-w --wrap FUNCTION", "Wrap the entire script in a function so it can also be sourced"
11-
option "-q --quiet", "Less verbose output"
11+
option "-q --quiet", "Disable on-screen progress report"
1212

1313
environment "BASHLY_SOURCE_DIR", "The path containing the bashly configuration and source files [default: src]"
1414
environment "BASHLY_TARGET_DIR", "The path to use for creating the bash script [default: .]"
@@ -19,13 +19,17 @@ class Generate < Base
1919
def run
2020
create_user_files
2121
create_master_script
22-
say "run !txtpur!#{master_script_path} --help!txtrst! to test your bash script" unless args['--quiet']
22+
quiet_say "run !txtpur!#{master_script_path} --help!txtrst! to test your bash script"
2323
end
2424

2525
private
2626

27+
def quiet_say(message)
28+
say message unless args['--quiet']
29+
end
30+
2731
def create_user_files
28-
say "creating user files in !txtgrn!#{Settings.source_dir}" unless args['--quiet']
32+
quiet_say "creating user files in !txtgrn!#{Settings.source_dir}"
2933

3034
create_file "#{Settings.source_dir}/initialize.sh", command.render(:default_initialize_script)
3135

@@ -51,17 +55,17 @@ def create_all_command_files
5155

5256
def create_file(file, content)
5357
if File.exist? file and !args['--force']
54-
say "skipped !txtgrn!#{file}!txtrst! (exists)" unless args['--quiet']
58+
quiet_say "skipped !txtgrn!#{file}!txtrst! (exists)"
5559
else
5660
File.write file, content
57-
say "created !txtgrn!#{file}"
61+
quiet_say "created !txtgrn!#{file}"
5862
end
5963
end
6064

6165
def create_master_script
6266
File.write master_script_path, script.code
6367
FileUtils.chmod "+x", master_script_path
64-
say "created !txtgrn!#{master_script_path}" unless args['--quiet']
68+
quiet_say "created !txtgrn!#{master_script_path}"
6569
end
6670

6771
def script

spec/approvals/cli/generate/help

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Options:
1212
Wrap the entire script in a function so it can also be sourced
1313

1414
-q --quiet
15-
Less verbose output
15+
Disable on-screen progress report
1616

1717
-h --help
1818
Show this help

spec/approvals/cli/generate/quiet

Lines changed: 0 additions & 3 deletions
This file was deleted.

spec/bashly/commands/generate_spec.rb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,9 @@
6161
end
6262

6363
it "generates the cli script" do
64-
expect { subject.run %w[generate --quiet] }.to output_approval('cli/generate/quiet')
64+
expect { subject.run %w[generate --quiet] }.to_not output.to_stdout
6565
expect(File).to exist(cli_script)
6666
end
67-
68-
context "when source files already exist" do
69-
before do
70-
expect { subject.run %w[generate --quiet] } #.to output_nothing
71-
File.write "#{source_dir}/download_command.sh", "some new user content"
72-
end
73-
74-
it "does not overwrite them" do
75-
expect { subject.run %w[generate --quiet] } #.to output_nothing
76-
expect(File.read "#{source_dir}/download_command.sh").to eq "some new user content"
77-
end
78-
end
79-
8067
end
8168

8269
context "with --wrap function" do

0 commit comments

Comments
 (0)