module YamlNormalizer::Helpers::ParamParser
Methods handling passing of additional params from CLI
Public Instance Methods
parse_params(*args)
click to toggle source
Parse the params provided to the service @param [Array] args - params passed to the service @return nil
# File lib/yaml_normalizer/helpers/param_parser.rb, line 12 def parse_params(*args) OptionParser.new do |opts| opts.banner = "Usage: #{program_name} [options] file1, file2..." opts.on('-v', '--version', 'Prints the yaml_normalizer version') { print_version } opts.on('-h', '--help', 'Prints this help') { print_help(opts) } end.parse(args) end
print_help(opts)
click to toggle source
Print current version of the tool @param [Option] opts - options of opt_parser object @return nil
# File lib/yaml_normalizer/helpers/param_parser.rb, line 29 def print_help(opts) print(opts) exit_success end
print_version()
click to toggle source
Print current version of the tool
# File lib/yaml_normalizer/helpers/param_parser.rb, line 21 def print_version print("#{YamlNormalizer::VERSION}\n") exit_success end
Private Instance Methods
exit_success()
click to toggle source
# File lib/yaml_normalizer/helpers/param_parser.rb, line 40 def exit_success exit unless ENV['ENV'] == 'test' end
program_name()
click to toggle source
# File lib/yaml_normalizer/helpers/param_parser.rb, line 36 def program_name $PROGRAM_NAME.split('/').last end