class Kojo::Commands::SingleCmd

Handle calls to the +kojo single+ command

Attributes

infile[R]
opts[R]
outdir[R]

Public Instance Methods

run() click to toggle source
# File lib/kojo/commands/single.rb, line 26
def run
  @opts = args['ARGS'].args_to_hash
  @outdir = args['--save']
  @infile = args['INFILE']
  run!
end

Private Instance Methods

run!() click to toggle source
# File lib/kojo/commands/single.rb, line 35
def run!
  template = Kojo::FrontMatterTemplate.new infile
  outdir ? write(template) : show(template)
end
show(template) click to toggle source
# File lib/kojo/commands/single.rb, line 40
def show(template)
  template.render opts do |file, output|
    say "\n!txtgrn!# #{file}"
    say output
  end
end
write(template) click to toggle source
# File lib/kojo/commands/single.rb, line 47
def write(template)
  template.render opts do |file, output|
    save "#{outdir}/#{file}", output
  end
end