class Kojo::Commands::ConfigCmd

Handle calls to the +kojo config+ command

Attributes

config_file[R]
gen[R]
import_base[R]
opts[R]
outdir[R]

Public Instance Methods

run() click to toggle source
# File lib/kojo/commands/config.rb, line 28
def run
  @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

Private Instance Methods

handle(file, output) click to toggle source
# File lib/kojo/commands/config.rb, line 54
def handle(file, output)
  if outdir
    save "#{outdir}/#{file}", output
  else
    say "\n!txtgrn!# #{file}"
    say output
  end
end
run!() click to toggle source
# File lib/kojo/commands/config.rb, line 45
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