Class: Psychic::CLI
- Inherits:
-
Thor
- Object
- Thor
- Psychic::CLI
- Defined in:
- lib/psychic/cli.rb
Constant Summary collapse
- BUILT_IN_TASKS =
%w(bootstrap)
Class Attribute Summary collapse
-
.extra_args ⇒ Object
Override Thor’s start to strip extra_args from ARGV before it’s processed.
Class Method Summary collapse
Instance Method Summary collapse
-
#sample(*sample_names) ⇒ Object
rubocop:enable Metrics/LineLength.
- #task(task_name) ⇒ Object
Class Attribute Details
.extra_args ⇒ Object
Override Thor’s start to strip extra_args from ARGV before it’s processed
11 12 13 |
# File 'lib/psychic/cli.rb', line 11 def extra_args @extra_args end |
Class Method Details
.start(given_args = ARGV, config = {}) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/psychic/cli.rb', line 13 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) given_args = given_args.slice(0, split_pos) end super given_args, config end |
Instance Method Details
#sample(*sample_names) ⇒ Object
rubocop:enable Metrics/LineLength
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/psychic/cli.rb', line 52 def sample(*sample_names) sample_names.each do | sample_name | say_status :executing, sample_name begin run_sample sample_name rescue Errno::ENOENT say_status :failed, "No code sample found for #{sample_name}", :red # TODO: Fail on missing? Fail fast? end end end |
#task(task_name) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/psychic/cli.rb', line 29 def task(task_name) result = runner.execute_task(task_name, *extra_args) result.error! say_status :success, task_name rescue Psychic::Shell::ExecutionError => e say_status :failed, task_name, :red say e.execution_result if e.execution_result end |