Class: Wip::CLI
- Inherits:
-
Thor
- Object
- Thor
- Wip::CLI
- Defined in:
- lib/wip/cli.rb
Overview
Thor-based command-line interface for wip.
Instance Method Summary collapse
- #build(*extra) ⇒ Object
- #config ⇒ Object
- #dispatch(name = nil, *arguments) ⇒ Object
- #doctor ⇒ Object
- #exec(*command) ⇒ Object
- #run_command(*command) ⇒ Object
- #shell_command ⇒ Object
- #version ⇒ Object
Instance Method Details
#build(*extra) ⇒ Object
35 36 37 38 |
# File 'lib/wip/cli.rb', line 35 def build(*extra) extra.shift if extra.first == '--' execute(builder.build(settings: load_config.command('build') || {}, extra: extra)) end |
#config ⇒ Object
30 31 32 |
# File 'lib/wip/cli.rb', line 30 def config puts YAML.dump(load_config.to_h) end |
#dispatch(name = nil, *arguments) ⇒ Object
64 65 66 67 68 |
# File 'lib/wip/cli.rb', line 64 def dispatch(name = nil, *arguments) raise ConfigError, 'A command is required' unless name execute(builder.custom(name, arguments)) end |
#doctor ⇒ Object
23 24 25 26 27 |
# File 'lib/wip/cli.rb', line 23 def doctor results = Doctor.new(loader: loader).call results.each { |item| puts "[#{item.level.to_s.upcase}] #{item.}" } exit(1) if results.any? { |item| item.level == :fail } end |
#exec(*command) ⇒ Object
42 43 44 |
# File 'lib/wip/cli.rb', line 42 def exec(*command) execute(builder.exec(command, interactive: [:interactive])) end |
#run_command(*command) ⇒ Object
48 49 50 |
# File 'lib/wip/cli.rb', line 48 def run_command(*command) execute(builder.run(command, interactive: [:interactive])) end |
#shell_command ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/wip/cli.rb', line 54 def shell_command configured = load_config.command('shell') return execute(builder.custom('shell', [])) if configured code = execute(builder.exec(['bash'], settings: { 'interactive' => true }, interactive: true)) execute(builder.exec(['sh'], settings: { 'interactive' => true }, interactive: true)) if code != 0 end |