Skip to content

Commit

Permalink
Merge pull request #58 from mgrecar/feature/no_launch_option
Browse files Browse the repository at this point in the history
Added a 'quiet' flag to the CLI options to suppress launch of the browse...
  • Loading branch information
makaroni4 committed Aug 22, 2014
2 parents 02d338e + 94eaec7 commit f974919
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/sandi_meter/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ class CommandParser
description: "HTML mode. Create folder, log data and output stats to HTML file.",
boolean: true

option :quiet,
short: "-q",
long: "--quiet",
description: "Do not open HTML report for graph option in browser.",
boolean: true

option :version,
short: "-v",
long: "--version",
Expand Down Expand Up @@ -112,7 +118,9 @@ def execute
html_generator.generate_details!(cli.config[:path], data)

index_html_path = File.join(cli.config[:path], 'sandi_meter/index.html')
open_in_browser(index_html_path)
unless cli.config[:quiet]
open_in_browser(index_html_path)
end
else
puts "WARNING!!! HTML mode works only if you scan folder."
end
Expand Down
16 changes: 16 additions & 0 deletions spec/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,21 @@
expect { cli.execute }.to raise_error(SystemExit)
end
end

context 'with the quiet flag passed in' do
before do
ARGV.push('-q')
ARGV.push('-g')
end
after do
ARGV.pop
ARGV.pop
end

it 'does not open the browser' do
cli.should_not_receive(:open_in_browser)
expect { cli.execute }.to raise_error(SystemExit)
end
end
end
end

1 comment on commit f974919

@mgrecar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@makaroni4 I don't see a version bump here. Definitely want to do that, the project is following Semantic Versioning, correct? Next time I issue a PR, should I be bumping the version? Only concern with that is the number may not be accurate, between when the PR is issued and when the code is commited, other changes could have been made.

Please sign in to comment.