Class: RbsMiniMagick::CLI
- Inherits:
-
Object
- Object
- RbsMiniMagick::CLI
- Defined in:
- lib/rbs_mini_magick/cli.rb
Overview
RbsMiniMagick::CLI
Instance Method Summary collapse
Constructor Details
#initialize(args, io:) ⇒ void
9 10 11 12 13 |
# File 'lib/rbs_mini_magick/cli.rb', line 9 def initialize(args, io:) @args = args @options = {} @io = io end |
Instance Method Details
#help ⇒ String
45 46 47 |
# File 'lib/rbs_mini_magick/cli.rb', line 45 def help parser.help end |
#run ⇒ Integer
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rbs_mini_magick/cli.rb', line 16 def run # rubocop:disable Metrics/MethodLength, Metrics/AbcSize parse! return 0 if help? || version? case [:command] when "generate" Generator.new( mini_magick_version: [:mini_magick_version], output_dir: [:output_dir] ).run else raise ArgumentError, "Invalid command: #{[:command]}" end 0 rescue Error => e io.puts e. 1 rescue OptionParser::InvalidOption, ArgumentError => e io.puts e. io.puts help 1 rescue Interrupt io.puts "Bye!" 1 end |