Class: Pechkin::CLI::CLIBuilder
- Inherits:
-
Object
- Object
- Pechkin::CLI::CLIBuilder
- Defined in:
- lib/pechkin/cli.rb
Overview
Command Line Parser Builder
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#build(parser) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize.
-
#initialize(options_keeper) ⇒ CLIBuilder
constructor
A new instance of CLIBuilder.
Constructor Details
#initialize(options_keeper) ⇒ CLIBuilder
Returns a new instance of CLIBuilder.
17 18 19 |
# File 'lib/pechkin/cli.rb', line 17 def initialize() = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/pechkin/cli.rb', line 16 def end |
Instance Method Details
#build(parser) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize
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 |
# File 'lib/pechkin/cli.rb', line 21 def build(parser) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize # rubocop:disable Metrics/LineLength parser. = 'Usage: pechkin [options]' parser.separator '' parser.on('-c', '--config CONFIG_FILE', 'default value is /etc/pechkin/config.yml') do |value| .config_file = value end parser.on('-p', '--port PORT', Integer) do |value| .port = value end parser.on('--pid PID_FILE') do |value| .pid_file = value end parser.on('--log-dir LOG_DIR') do |value| .log_dir = value end parser.separator '' parser.separator 'Common options:' parser.on_tail('-h', '--help', 'Show this message') do puts parser exit end # Another typical switch to print the version. parser.on_tail('--version', 'Show version') do puts Version.version_string exit end # rubocop:enable Metrics/LineLength end |