lib/attractor/cli.rb in attractor-1.0.1 vs lib/attractor/cli.rb in attractor-1.0.2

- old
+ new

@@ -27,22 +27,25 @@ desc 'report', 'Generates an HTML report' option :format, aliases: :f, default: 'html' option :file_prefix, aliases: :p option :watch, aliases: :w, type: :boolean option :type, aliases: :t + option :no_open_browser, type: :boolean + option :ci, type: :boolean def report file_prefix = options[:file_prefix] calculators = Attractor.calculators_for_type(options[:type], file_prefix) + open_browser = !(options[:no_open_browser] || options[:ci]) if options[:watch] puts 'Listening for file changes...' - Attractor::HtmlReporter.new(file_prefix: file_prefix, calculators: calculators).watch + Attractor::HtmlReporter.new(file_prefix: file_prefix, calculators: calculators, open_browser: open_browser).watch else case options[:format] when 'html' - Attractor::HtmlReporter.new(file_prefix: file_prefix, calculators: calculators).report + Attractor::HtmlReporter.new(file_prefix: file_prefix, calculators: calculators, open_browser: open_browser).report else - Attractor::HtmlReporter.new(file_prefix: file_prefix, calculators: calculators).report + Attractor::HtmlReporter.new(file_prefix: file_prefix, calculators: calculators, open_browser: open_browser).report end end rescue RuntimeError => e puts "Runtime error: #{e.message}" end @@ -50,21 +53,24 @@ desc 'serve', 'Serves the report on localhost' option :format, aliases: :f, default: 'html' option :file_prefix, aliases: :p option :watch, aliases: :w, type: :boolean option :type, aliases: :t + option :no_open_browser, type: :boolean + option :ci, type: :boolean def serve file_prefix = options[:file_prefix] + open_browser = !(options[:no_open_browser] || options[:ci]) calculators = Attractor.calculators_for_type(options[:type], file_prefix) if options[:watch] puts 'Listening for file changes...' - Attractor::SinatraReporter.new(file_prefix: file_prefix, calculators: calculators).watch + Attractor::SinatraReporter.new(file_prefix: file_prefix, calculators: calculators, open_browser: open_browser).watch else case options[:format] when 'html' - Attractor::SinatraReporter.new(file_prefix: file_prefix, calculators: calculators).report + Attractor::SinatraReporter.new(file_prefix: file_prefix, calculators: calculators, open_browser: open_browser).report else - Attractor::SinatraReporter.new(file_prefix: file_prefix, calculators: calculators).report + Attractor::SinatraReporter.new(file_prefix: file_prefix, calculators: calculators, open_browser: open_browser).report end end end end end