Class: Kojo::Commands::ConfigCmd

Inherits:
MisterBin::Command
  • Object
show all
Defined in:
lib/kojo/commands/config.rb

Overview

Handle calls to the kojo config command

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#config_fileObject (readonly)

Returns the value of attribute config_file.



7
8
9
# File 'lib/kojo/commands/config.rb', line 7

def config_file
  @config_file
end

#genObject (readonly)

Returns the value of attribute gen.



7
8
9
# File 'lib/kojo/commands/config.rb', line 7

def gen
  @gen
end

#import_baseObject (readonly)

Returns the value of attribute import_base.



7
8
9
# File 'lib/kojo/commands/config.rb', line 7

def import_base
  @import_base
end

#optsObject (readonly)

Returns the value of attribute opts.



7
8
9
# File 'lib/kojo/commands/config.rb', line 7

def opts
  @opts
end

#outdirObject (readonly)

Returns the value of attribute outdir.



7
8
9
# File 'lib/kojo/commands/config.rb', line 7

def outdir
  @outdir
end

Instance Method Details

#run(args) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/kojo/commands/config.rb', line 25

def run(args)
  @config_file = args['CONFIG']
  @outdir = args['--save']
  @opts = args['ARGS'].args_to_hash
  @import_base = args['--imports']
  argfile = args['--args']

  if argfile
    fileopts = YAML.load_file(argfile).symbolize_keys
    @opts = fileopts.merge opts
  end

  run!
end

#run!Object



40
41
42
43
44
45
46
47
# File 'lib/kojo/commands/config.rb', line 40

def run!
  config = Kojo::Config.new config_file
  config.import_base = import_base if import_base

  config.generate opts do |file, output|
    handle file, output
  end
end