Class: Webcmd::Options
- Inherits:
-
Object
- Object
- Webcmd::Options
- Extended by:
- Forwardable
- Defined in:
- lib/webcmd/options.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ Options
constructor
A new instance of Options.
- #parse! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Options
Returns a new instance of Options.
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 35 36 37 38 |
# File 'lib/webcmd/options.rb', line 8 def initialize(argv) @parser = OptionParser.new(argv) do |opts| opts. = "Usage: webcmd [options]" opts.on '-o', '--host HOST', 'listen on HOST (default: 0.0.0.0)' do |host| [:Host] = host end opts.on '-p', '--port PORT', 'use PORT (default: 9292)' do |port| @options[:Port] = port end opts.on '-t', '--threads INT', 'min:max threads to use (default 0:1)' do |threads| @options[:Threads] = threads end opts.on '-D', '--daemonize', 'run daemonized in the background' do |d| @options[:daemonize] = !!d end opts.on_tail '-h', '--help', 'show this message' do puts opts exit end opts.on_tail '--version', 'show version' do puts "webcmd #{Webcmd::VERSION}" exit end end end |
Instance Method Details
#parse! ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/webcmd/options.rb', line 40 def parse! @options = { app: {} } @parser.parse! @options[:app][:command] = ENV['COMMAND'] @options[:app][:token] = ENV['TOKEN'] @options end |