Class: Hologram::CLI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CLI

Returns a new instance of CLI.



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

def initialize(args)
  @args = args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



5
6
7
# File 'lib/hologram/cli.rb', line 5

def args
  @args
end

Instance Method Details

#runObject



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

def run
  return setup if args[0] == 'init'

  #support passing the config file with no command line flag
  config = args[0].nil? ? 'hologram_config.yml' : args[0]

  OptionParser.new do |opt|
    opt.on_tail('-h', '--help', 'Show this message.') { puts opt; exit }
    opt.on_tail('-v', '--version', 'Show version.') { puts "hologram #{Hologram::VERSION}"; exit }
    opt.on('-c', '--config FILE', 'Path to config file. Default: hologram_config.yml') { |config_file| config = config_file }
    opt.parse!(args)
  end

  config.nil? ? build : build(config)

end