Module: Af::OptionParser::Interface
- Included in:
- Af::OptionParser
- Defined in:
- lib/fiksu-af/option_parser/interface.rb
Instance Method Summary collapse
-
#opt(long_name, *extra_stuff, &b) ⇒ Object
Update Options for the provided long switch option name.
-
#opt_check(var_name, *extra_stuff, &b) ⇒ Object
Update OptionChecks for the provided group option name.
-
#opt_error(text) ⇒ Object
used by application code to note an error and exit.
-
#opt_group(group_name, *extra_stuff, &b) ⇒ Object
Update OptionGroups for the provided group option name.
-
#opt_select(var_name, *extra_stuff, &b) ⇒ Object
Update OptionSelects for the provided group option name.
-
#process_command_line_options(af_option_interests) ⇒ Object
Collect and process all of the switches (values) on the command line, as previously configured.
-
#usage ⇒ Object
Returns a string detailing application usage.
Instance Method Details
#opt(long_name, *extra_stuff, &b) ⇒ Object
Update Options for the provided long switch option name. Just a helper to UI method “opt”
15 16 17 |
# File 'lib/fiksu-af/option_parser/interface.rb', line 15 def opt(long_name, *extra_stuff, &b) self.class.opt(long_name, *extra_stuff, &b) end |
#opt_check(var_name, *extra_stuff, &b) ⇒ Object
Update OptionChecks for the provided group option name. Just a helper to UI method “opt_check”
27 28 29 |
# File 'lib/fiksu-af/option_parser/interface.rb', line 27 def opt_check(var_name, *extra_stuff, &b) self.class.opt_check(var_name, *extra_stuff, &b) end |
#opt_error(text) ⇒ Object
used by application code to note an error and exit
4 5 6 |
# File 'lib/fiksu-af/option_parser/interface.rb', line 4 def opt_error(text) self.class.opt_error(text) end |
#opt_group(group_name, *extra_stuff, &b) ⇒ Object
Update OptionGroups for the provided group option name. Just a helper to UI method “opt_group”
21 22 23 |
# File 'lib/fiksu-af/option_parser/interface.rb', line 21 def opt_group(group_name, *extra_stuff, &b) self.class.opt_group(group_name, *extra_stuff, &b) end |
#opt_select(var_name, *extra_stuff, &b) ⇒ Object
Update OptionSelects for the provided group option name. Just a helper to UI method “opt_select”
33 34 35 |
# File 'lib/fiksu-af/option_parser/interface.rb', line 33 def opt_select(var_name, *extra_stuff, &b) self.class.opt_select(var_name, *extra_stuff, &b) end |
#process_command_line_options(af_option_interests) ⇒ Object
Collect and process all of the switches (values) on the command line, as previously configured.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fiksu-af/option_parser/interface.rb', line 39 def (af_option_interests) # Iterate through all options in the class heirachy. # Create instance variables and accessor methods for each. option_finder = OptionFinder.new(af_option_interests) = option_finder. .each(&:instantiate_target_variable) # Fetch the actual switches (and values) from the command line. = GetOptions.new() # Iterate through the command line options. Print and exit if the switch # is invalid, help or app version. Otherwise, process and handle. begin .each do |long_name, argument| option_finder.find_option(long_name).evaluate_and_set_target(argument) end rescue GetoptLong::Error, Error => e opt_error e. end end |
#usage ⇒ Object
Returns a string detailing application usage.
9 10 11 |
# File 'lib/fiksu-af/option_parser/interface.rb', line 9 def usage return self.class.usage end |