Class: Fuelcell::Parser::CmdArgsStrategy

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

Instance Method Summary collapse

Instance Method Details

#call(args) ⇒ Array

Extract arguments that form the command to be executed.

This will collect all arguments up to the first option or the ignore symbol –. It separates and returns the command args as an array of strings that form a heirarchal route to the command. These command args are removed from the raw arg list

Parameters:

  • raw (Array)

    args from ARGV

Returns:

  • (Array)


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fuelcell/parser/cmd_args_strategy.rb', line 15

def call(args)
  cmd_args = []
  while item = args.shift
    if item.start_with?('-')
      args.unshift(item)
      break
    end
    cmd_args << item
  end
  cmd_args
end