lib/sandi_meter/cli.rb in sandi_meter-0.0.6 vs lib/sandi_meter/cli.rb in sandi_meter-1.0.0

- old
+ new

@@ -18,14 +18,20 @@ short: "-l", long: "--log", description: "Show syntax error and indentation log output", boolean: true + option :details, + short: "-d", + long: "--details", + description: "CLI mode. Show details (path, line number)", + boolean: true + option :graph, short: "-g", long: "--graph", - description: "Create folder and log data to graph", + description: "HTML mode. Create folder, log data and output stats to HTML file.", boolean: true option :help, short: "-h", long: "--help", @@ -51,22 +57,30 @@ show_sandi_rules exit 0 end scanner = SandiMeter::FileScanner.new(cli.config[:log]) - data = scanner.scan(cli.config[:path]) + data = scanner.scan(cli.config[:path], cli.config[:details] || cli.config[:graph]) + formatter = SandiMeter::Formatter.new formatter.print_data(data) if cli.config[:graph] - logger = SandiMeter::Logger.new - logger.log!(cli.config[:path], data) + if File.directory?(cli.config[:path]) + logger = SandiMeter::Logger.new + logger.log!(cli.config[:path], data) - html_generator = SandiMeter::HtmlGenerator.new - html_generator.copy_assets!(cli.config[:path]) - html_generator.generate_data!(cli.config[:path]) + html_generator = SandiMeter::HtmlGenerator.new + html_generator.copy_assets!(cli.config[:path]) + html_generator.generate_data!(cli.config[:path]) + html_generator.generate_details!(cli.config[:path], data) + + system "open sandi_meter/index.html" + else + puts "WARNING!!! HTML mode works only if you scan folder." + end end end def self.show_sandi_rules puts %( @@ -75,6 +89,6 @@ 3. 4 params per method call (and don't even try cheating with hash params) 4. 1 instance variables per controller' action ) end end -end \ No newline at end of file +end