lib/sandi_meter/cli.rb in sandi_meter-1.0.2 vs lib/sandi_meter/cli.rb in sandi_meter-1.0.3
- old
+ new
@@ -1,9 +1,11 @@
+# encoding: utf-8
require 'mixlib/cli'
require 'sandi_meter/file_scanner'
require 'sandi_meter/formatter'
require 'sandi_meter/logger'
+require 'sandi_meter/version'
require 'sandi_meter/html_generator'
module SandiMeter
class CommandParser
include Mixlib::CLI
@@ -30,10 +32,16 @@
short: "-g",
long: "--graph",
description: "HTML mode. Create folder, log data and output stats to HTML file.",
boolean: true
+ option :version,
+ short: "-v",
+ long: "--version",
+ description: "Gem version",
+ boolean: true
+
option :help,
short: "-h",
long: "--help",
description: "Help",
on: :tail,
@@ -51,10 +59,16 @@
class CLI
def self.execute
cli = CommandParser.new
cli.parse_options
+ if cli.config[:version]
+ # stolen from gem 'bubs' :)
+ puts "SandiMeter ".tr('A-Za-z1-90', 'Ⓐ-Ⓩⓐ-ⓩ①-⑨⓪').split('').join(' ') + SandiMeter::VERSION
+ exit 0
+ end
+
if cli.config[:rules]
show_sandi_rules
exit 0
end
@@ -72,9 +86,17 @@
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)
+
+ # put ignore file
+ ignore_file_path = File.join(cli.config[:path], 'sandi_meter', '.sandi_meter')
+ if File.directory?(cli.config[:path]) && !File.exists?(ignore_file_path)
+ File.open(ignore_file_path, "w") do |file|
+ file.write %w(db vendor).join("\n")
+ end
+ end
index_html_path = File.join(cli.config[:path], 'sandi_meter/index.html')
system "open #{index_html_path}"
else
puts "WARNING!!! HTML mode works only if you scan folder."