Class: Inventory::Server::CLI
- Inherits:
-
Object
- Object
- Inventory::Server::CLI
- Defined in:
- lib/inventory/server/cli.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #parse!(args) ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
11 12 13 |
# File 'lib/inventory/server/cli.rb', line 11 def initialize() @options = {} end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/inventory/server/cli.rb', line 9 def @options end |
Instance Method Details
#parse!(args) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/inventory/server/cli.rb', line 15 def parse!(args) OptionParser.new do|opts| opts. = "Usage: server [options]" opts.separator "" opts.separator "Specific options:" opts.on("--host HOST", String, "IP or hostname to listen on") do |h| @options[:host] = h end opts.on("--smtp_port PORT", Integer, "SMTP port to listen on") do |p| @options[:smtp_port] = p end opts.on("-es", "--es_host URL", String, "ElasticSerach HTTP URL") do |url| @options[:es_host] = url end opts.on("-o", "--output OUTPUT", String, "Log destination stdout/stderr/file") do |o| @options[:logger] = o end opts.on("-l", "--level LEVEL", ['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'], "log level that will be printed DEBUG/INFO/WARN/ERROR/FATAL") do |l| @options[:log_level] = l end opts.on("-d", "--[no-]debug", "how more details, need log_level on DEBUG") do |d| @options[:debug] = d end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.on_tail("--version", "Show version") do puts VERSION exit end end.parse! args @options end |