Class: Fuelcell::Parser::ShortOptNoSpaceHandler

Inherits:
BaseHandler
  • Object
show all
Defined in:
lib/fuelcell/parser/short_opt_no_space_handler.rb

Overview

Handles short options that express their value without using a space like -uroot where the short opt is -u and value is root

Instance Method Summary collapse

Methods inherited from BaseHandler

#arg?, #assign_opt_value, #cast, #cast_array, #cast_bool, #cast_hash, #cast_numeric, #find_opt, #found_opt_flag, #take_first_arg

Instance Method Details

#call(cmd, args, opts) ⇒ Boolean

Parameters:

  • cmd (Fuelcell::Command)
  • args (Array)

    raw args from ARGV

  • opts (Hash)

    stores the found opts

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fuelcell/parser/short_opt_no_space_handler.rb', line 10

def call(cmd, args, opts)
  arg = take_first_arg(args) do |text|
    !(text =~ /^-([a-zA-Z]{2,})$/).nil?
  end
  return false unless arg

  return true if handle_no_space_value(cmd, opts, args, arg)

  arg[0] = '' # remove the dash
  handle_cluster(cmd, opts, arg)

  true
end