Sha256: f0779d58b126d32e8f02081f18642c33a74d6afb1df2d8adb09a25c8e748e72b
Contents?: true
Size: 1.18 KB
Versions: 3
Compression:
Stored size: 1.18 KB
Contents
require "optparse" require "lapidarius/cutter" require "lapidarius/renderer" module Lapidarius class CLI class NoGemError < ArgumentError; end def initialize(args, io = STDOUT) @args = args @io = io @gem = nil @recursive = nil end def call(cmd_klass = Command) parser.parse!(@args) fail NoGemError, "please specify the name of an installed gem!" unless @gem gem = cutter(cmd_klass).call renderer(gem).call(@io) end private def parser OptionParser.new do |opts| opts.banner = "Usage: ./bin/lapidarius --gem=sinatra --recursive" opts.on("-gGEM", "--gem=GEM", "The gem name to scan") do |gem| @gem = gem 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, cmd_klass: cmd_klass) end private def renderer(gem) Lapidarius::Renderer::new(gem: gem, recursive: @recursive) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lapidarius-1.1.1 | lib/lapidarius/cli.rb |
lapidarius-1.1.0 | lib/lapidarius/cli.rb |
lapidarius-1.0.0 | lib/lapidarius/cli.rb |