Class: Options
- Inherits:
-
Object
- Object
- Options
- Defined in:
- lib/options.rb
Overview
Defines options to be executed against the NeXpose API
Class Method Summary collapse
Class Method Details
.parse(args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/options.rb', line 8 def self.parse(args) = OpenStruct.new .port = 3780 .host = 'localhost' .silo_id = nil option_parser = OptionParser.new do |option_parser| option_parser.on("-h host", "The network address of the NeXpose instance - Defaults to 'localhost'") { |arg| .host=arg.chomp } option_parser.on("-u user_name", "The NeXpose user name - Required") { |arg| .user=arg.chomp } option_parser.on("-p password", "The NeXpose password - Required") { |arg| .password=arg.chomp } option_parser.on("-s silo-id", "The Silo ID - Optional") { |arg| .silo_id=arg.chomp } option_parser.on("--port port", "The NSC port - Defaults to 3780") { |arg| .port=arg.chomp } option_parser.on_tail("--help", "Help") do puts option_parser exit 0 end end begin option_parser.parse!(args) rescue OptionParser::ParseError => e puts "#{e}\n\n#{option_parser}" exit 1 end end |