lib/lapidarius/cli.rb in lapidarius-2.0.1 vs lib/lapidarius/cli.rb in lapidarius-2.1.0

- old
+ new

@@ -6,19 +6,18 @@ class CLI def initialize(args, io = STDOUT) @args = args @io = io @gem = nil - @version = nil @recursive = nil end def call(cmd_klass = Command) parser.parse!(@args) return @io.puts("specify gem name as: '-g gem_name'") unless @gem - gem = cutter(cmd_klass).call - renderer(gem).call(@io) + obj = Lapidarius::Cutter.new(@gem, cmd_klass).call + Lapidarius::Renderer::new(obj, @recursive).call(@io) rescue Gem::NotInstalledError => e @io.puts e.message.sub("specified", @gem) end private def parser @@ -27,30 +26,18 @@ opts.on("-gGEM", "--gem=GEM", "The gem name to scan") do |gem| @gem = gem end - opts.on("-vVERSION", "--version=VERSION", "Specify the gem version") do |version| - @version = version - end - opts.on("-r", "--recursive", "Print dependencies recursively") do |recursive| @recursive = recursive end opts.on("-h", "--help", "Prints this help") do @io.puts opts exit end end - end - - private def cutter(cmd_klass) - @cutter = Lapidarius::Cutter.new(gem: @gem, version: @version, cmd_klass: cmd_klass) - end - - private def renderer(gem) - Lapidarius::Renderer::new(gem: gem, recursive: @recursive) end end end