Class: ConventionalModels::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/conventional_models/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/conventional_models/cli.rb', line 7

def options
  @options
end

Instance Method Details

#run(args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/conventional_models/cli.rb', line 9

def run(args)
  opts = OptionParser.new
  @options = Options.new
  opts.on('-v', '--version')    { @options.output_version = true }
  opts.on('-h', '--help')       { @options.output_help = opts }
  opts.on('-s', '--skip-configure')    { @options.skip_configure = true }  
  opts.on('-c', '--config FILE')      { |file| @options.config = file }
  opts.on('-e', '--environment ENV')      { |env| @options.environment = env }
  opts.on('-V', '--verbose')      { |env| @options.verbose = true }
  
  begin
    opts.parse!(args)
    return output_version if @options.output_version
    return output_help(@options.output_help) if @options.output_help
    output_options if @options.verbose
    run_console
  rescue
    puts opts
  end
end