Class: ThreddedCreateApp::CLI::Flags
- Inherits:
-
Object
- Object
- ThreddedCreateApp::CLI::Flags
- Defined in:
- lib/thredded_create_app/cli.rb
Overview
rubocop:enable Metrics/AbcSize,Metrics/BlockLength,Metrics/MethodLength
Instance Method Summary collapse
-
#bool(as, short = nil, long, desc) ⇒ Object
rubocop:disable Style/OptionalArguments.
-
#initialize(op, options) ⇒ Flags
constructor
A new instance of Flags.
Constructor Details
#initialize(op, options) ⇒ Flags
139 140 141 142 |
# File 'lib/thredded_create_app/cli.rb', line 139 def initialize(op, ) @op = op = end |
Instance Method Details
#bool(as, short = nil, long, desc) ⇒ Object
rubocop:disable Style/OptionalArguments
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/thredded_create_app/cli.rb', line 145 def bool(as, short = nil, long, desc) flag_args = [short, long].compact if long.start_with?('--[no-]') desc += " (default: #{DEFAULTS[as]})" if DEFAULTS[as] @op.on(*flag_args, desc) do |v| [as] = v yield v if block_given? end else @op.on(*flag_args, desc) do [as] = !long.start_with?('--no-') yield [as] if block_given? end end end |