class CLI::CommonOptionParser

Attributes

options[RW]

Public Instance Methods

add_required_argument(*args) click to toggle source
# File lib/cli.rb, line 45
def add_required_argument(*args)  [*args].each { |arg| required_arguments << arg } end
Also aliased as: add_required_arguments
add_required_arguments(*args)
check_required_arguments() click to toggle source
# File lib/cli.rb, line 53
def check_required_arguments
  _missing_arguments = missing_required_arguments
  unless _missing_arguments.empty?
    abort "Missing Required Arguments: #{_missing_arguments.map { |v| (v.is_a?(Hash) ? v.values.first : v).to_s.sub('_', '-')}.join(', ')}\n#{self.to_s}"
  end
end
missing_required_arguments() click to toggle source
# File lib/cli.rb, line 48
def missing_required_arguments
  puts "Options #{options}"
  required_arguments.dup.delete_if { |a| options.has_key?(a.is_a?(Hash) ? a.keys.first : a) }
end
parse_common() click to toggle source

def options=(value)

#puts "Setting #{self.class.name}[#{self.object_id}] options => (#{value.class.name}[#{value.object_id}]) #{value}"
@options = value

end

def options

#puts "Getting #{self.class.name}[#{self.object_id}] options. #{@options}"
@options

end

# File lib/cli.rb, line 33
def parse_common
  #puts "Parsing #{self.class.name}[#{self.object_id}] options. #{@options}"
  parse!(ARGV.dup)

  options_file_path = options[:options_file_path]
  # Make sure that options from the command line override those from the options file
  parse!(ARGV.dup) if options_file_path and load(options_file_path)

  check_required_arguments
end
required_arguments() click to toggle source
# File lib/cli.rb, line 44
def required_arguments; @required_arguments ||= [ ] end