Class: Up::CLI::Options
- Inherits:
-
OptionParser
- Object
- OptionParser
- Up::CLI::Options
- Defined in:
- lib/up/cli.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize ⇒ Options
constructor
A new instance of Options.
- #parse! ⇒ Object
Constructor Details
#initialize ⇒ 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 39 40 41 42 43 44 45 |
# File 'lib/up/cli.rb', line 8 def initialize super @options = {} self. = 'Usage: up [options]' separator '' on('-h', '--help', 'Show this message') do puts self exit end on('-p', '--port PORT', String, 'Port number the server will listen to. Default: 3000') do |port| [:port] = port.to_i end on('-b', '--bind ADDRESS', String, 'Address the server will listen to. Default: localhost') do |host| [:host] = host end on('-s', '--secure', "Use secure sockets.\nWhen using secure sockets, the -a, -c and -k options must be provided") do [:scheme] = 'https' end on('-a', '--ca-file FILE', String, 'File with CA certs') do |ca_file| [:ca_file] = ca_file end on('-c', '--cert-file FILE', String, 'File with the servers certificate') do |cert_file| [:cert_file] = cert_file end on('-k', '--key-file FILE', String, 'File with the servers certificate') do |key_file| [:key_file] = key_file end on('-l', '--log-file FILE', String, 'Log file') do |log_file| [:logger] = Logger.new(File.new(log_file, 'a+')) end on('-v', '--version', 'Show version') do puts "Up! v#{Up::VERSION}" exit end on('-w', '--workers NUMBER', 'For clusters, the number of workers to run. Default: number of processors') do |workers| [:workers] = workers.to_i end end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/up/cli.rb', line 7 def @options end |
Instance Method Details
#parse! ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/up/cli.rb', line 47 def parse! super if [:scheme] == 'https' if ![:ca_file] || ![:cert_file] || ![:key_file] puts "When using -s or --secure the -a,-c- and -k options must be given too!" exit 2 end end end |