Method: MiGA::Cli::OptHelper#opt_flag

Defined in:
lib/miga/cli/opt_helper.rb

#opt_flag(opt, flag, description, sym = nil) ⇒ Object

Add a flag (true/false) to the OptionParser opt defined by flag (without –) and description, and save it in the CLI as sym. If sym is nil, flag is used as Symbol



167
168
169
170
# File 'lib/miga/cli/opt_helper.rb', line 167

def opt_flag(opt, flag, description, sym = nil)
  sym = flag.to_sym if sym.nil?
  opt.on("--#{flag.to_s.tr('_', '-')}", description) { |v| self[sym] = v }
end