Class: Psychic::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/psychic/cli.rb

Direct Known Subclasses

Runner::RunnerCLI

Constant Summary collapse

BUILT_IN_TASKS =
%w(bootstrap)

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.extra_argsObject

Override Thor’s start to strip extra_args from ARGV before it’s processed



10
11
12
# File 'lib/psychic/cli.rb', line 10

def extra_args
  @extra_args
end

Class Method Details

.start(given_args = ARGV, config = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/psychic/cli.rb', line 12

def start(given_args = ARGV, config = {})
  if given_args && (split_pos = given_args.index('--'))
    @extra_args = given_args.slice(split_pos + 1, given_args.length).map do | arg |
      # Restore quotes
      next unless arg.match(/\=/)
      lhs, rhs = arg.split('=')
      lhs = "\"#{lhs}\"" if lhs.match(/\s/)
      rhs = "\"#{rhs}\"" if rhs.match(/\s/)
      [lhs, rhs].join('=')
    end
    given_args = given_args.slice(0, split_pos)
  end
  super given_args, config
end