class GemOptions
Public Class Methods
create_parser()
click to toggle source
# File lib/nexpose_ticketing/utilities/gem_options.rb, line 7 def self.create_parser @parser = OptionParser.new self end
parse()
click to toggle source
Parses the options to make them available
# File lib/nexpose_ticketing/utilities/gem_options.rb, line 88 def self.parse @parser.parse! end
with_configuration_encryption(config_paths, enc_path = nil)
click to toggle source
For setting encryption switch. Can be set to work with two configurations Config_paths is an array
# File lib/nexpose_ticketing/utilities/gem_options.rb, line 34 def self.with_configuration_encryption(config_paths, enc_path = nil) @parser.on('-e', '--encrypt_config', 'Encrypt the configuration file(s) without running the gem') do |e| ConfigParser.get_config(config_paths.first, enc_path) unless enc_path.nil? ConfigParser.get_config(config_paths.last) puts "\nConfiguration File(s) Encrypted" exit end self end
with_help()
click to toggle source
# File lib/nexpose_ticketing/utilities/gem_options.rb, line 46 def self.with_help @parser.on_tail('-h', '--help', 'Show this message') do |h| puts @parser exit end self end
with_help_and_version(gem, version)
click to toggle source
# File lib/nexpose_ticketing/utilities/gem_options.rb, line 62 def self.with_help_and_version(gem, version) with_help with_version(gem, version) self end
with_options()
click to toggle source
Header for options list
# File lib/nexpose_ticketing/utilities/gem_options.rb, line 20 def self.with_options @parser.separator 'Options:' self end
with_other_option(short_switch, long_switch, description, &handler)
click to toggle source
Method to allow integrations to create own options, with both short and long switches and description. Handler is the block to run when option is called.
# File lib/nexpose_ticketing/utilities/gem_options.rb, line 71 def self.with_other_option(short_switch, long_switch, description, &handler) @parser.on("-#{short_switch}", "--#{long_switch}", description) do |opt| handler.call end end
with_single_switch_option(identifier, switch, description, &handler)
click to toggle source
Method to allow integrations to create own options, with only one size of switch and description. '-' for short switches and '–' for long switches is required. Handler is the block to run when option is called.
# File lib/nexpose_ticketing/utilities/gem_options.rb, line 81 def self.with_single_switch_option(identifier, switch, description, &handler) @parser.on("#{identifier}#{switch}", description) do |opt| handler.call end end
with_version(gem, version)
click to toggle source
# File lib/nexpose_ticketing/utilities/gem_options.rb, line 54 def self.with_version(gem, version) @parser.on_tail('--version', 'Version Information') do |v| puts "#{gem} #{version}" exit end self end