Class: Hako::CLI::ShowYaml

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

Instance Method Summary collapse

Instance Method Details

#parse!(argv) ⇒ Object



146
147
148
149
150
151
152
153
# File 'lib/hako/cli.rb', line 146

def parse!(argv)
  parser.parse!(argv)
  @yaml_path = argv.first
  if @yaml_path.nil?
    puts parser.help
    exit 1
  end
end

#parserObject



155
156
157
158
159
160
# File 'lib/hako/cli.rb', line 155

def parser
  @parser ||= OptionParser.new do |opts|
    opts.banner = 'hako show-yaml FILE'
    opts.version = VERSION
  end
end

#run(argv) ⇒ Object



140
141
142
143
144
# File 'lib/hako/cli.rb', line 140

def run(argv)
  parse!(argv)
  require 'hako/yaml_loader'
  puts YamlLoader.new.load(Pathname.new(@yaml_path)).to_yaml
end