lib/attractor/cli.rb in attractor-0.2.1 vs lib/attractor/cli.rb in attractor-0.3.0

- old
+ new

@@ -34,7 +34,25 @@ else Attractor::HtmlReporter.new(file_prefix: options[:file_prefix]).report end end end + + desc 'serve', 'Serves the report on localhost' + option :format, aliases: :f, default: 'html' + option :file_prefix, aliases: :p + option :watch, aliases: :w, type: :boolean + def serve + if options[:watch] + puts 'Listening for file changes...' + Attractor::RackReporter.new(file_prefix: options[:file_prefix]).watch + else + case options[:format] + when 'html' + Attractor::RackReporter.new(file_prefix: options[:file_prefix]).report + else + Attractor::RackReporter.new(file_prefix: options[:file_prefix]).report + end + end + end end end