class Yamlook::Cli
Yamlook
CLI
Attributes
arguments[R]
options[R]
Public Class Methods
new(arguments)
click to toggle source
# File lib/yamlook/cli.rb, line 11 def initialize(arguments) @arguments = arguments @options = {} opt_parser.parse!(@arguments) show_help! if @arguments.empty? rescue OptionParser::InvalidOption => e puts e exit 1 end
Public Instance Methods
argument()
click to toggle source
# File lib/yamlook/cli.rb, line 23 def argument @arguments.first end
Private Instance Methods
opt_parser()
click to toggle source
rubocop:disable Metrics/MethodLength
# File lib/yamlook/cli.rb, line 30 def opt_parser @opt_parser ||= OptionParser.new do |opts| opts.banner = 'Usage: yamlook KEYS' opts.separator '' opts.separator 'Example: yamlook some.deep.key.in.you.yaml.file' opts.separator '' opts.separator 'Options:' opts.on_tail('-h', '--help', 'Show this message') do puts opts.help exit end opts.on_tail('--version', 'Show version') do puts Yamlook::VERSION exit end end end
show_help!()
click to toggle source
rubocop:enable Metrics/MethodLength
# File lib/yamlook/cli.rb, line 51 def show_help! puts opt_parser.help exit end