Class: Crosstest::Psychic::CLI

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

Defined Under Namespace

Classes: List, Show

Constant Summary collapse

BUILT_IN_TASKS =
%w(bootstrap)

Instance Method Summary collapse

Instance Method Details

#script(script_name = nil) ⇒ Object

rubocop:disable Metrics/AbcSize


62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/crosstest/psychic/cli.rb', line 62

def script(script_name = nil) # rubocop:disable Metrics/AbcSize
  abort 'You must specify a script name, run `psychic list scripts` for a list of known scripts' unless script_name
  command = psychic.command_for_script(script_name, *extra_args)
  if options[:print]
    say command
  else
    psychic.execute command
  end
rescue ScriptNotRunnable => e
  abort "No usable command was found for task #{task_alias}"
rescue Crosstest::Shell::ExecutionError => e
  say_status :failed, task_alias, :red
  say e.execution_result if e.execution_result
end

#task(task_alias = nil) ⇒ Object

rubocop:disable Metrics/AbcSize


30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/crosstest/psychic/cli.rb', line 30

def task(task_alias = nil) # rubocop:disable Metrics/AbcSize
  abort 'You must specify a task name, run `psychic list tasks` for a list of known tasks' unless task_alias
  command = psychic.task(task_alias, *extra_args)
  if options[:print]
    say command
  else
    psychic.execute command
  end
rescue TaskNotImplementedError => e
  abort "No usable command was found for task #{task_alias}"
rescue Crosstest::Shell::ExecutionError => e
  say_status :failed, task_alias, :red
  say e.execution_result if e.execution_result
end