lib/maprename/cli.rb in maprename-0.1.0 vs lib/maprename/cli.rb in maprename-0.1.1

- old
+ new

@@ -1,8 +1,14 @@ require 'optparse' require 'maprename/app' +module Kernel + def debug(msg) + puts msg if $debug + end +end + module Maprename class Cli def initialize @options = {} parse_options! @@ -18,10 +24,15 @@ opts.on("-d", "--dry", "dry run") do @options[:dry] = true end + opts.on("-D", "--debug", "debug") do + @options[:debug] = true + $debug = true + end + opts.on("-h", "--help", "Prints this help") do puts opts exit end end @@ -37,9 +48,10 @@ config = config_file unless File.exists?(config) puts @raw_options exit 1 end - Maprename::App.new(config_file).run!(@options[:dry]) + debug "CLI Options: #{@options}" + Maprename::App.new(config_file).run!(@options) end end end