Module: Buildkite::Builder::Commands

Defined in:
lib/buildkite/builder/commands.rb,
lib/buildkite/builder/commands/run.rb,
lib/buildkite/builder/commands/preview.rb,
lib/buildkite/builder/commands/abstract.rb

Defined Under Namespace

Classes: Abstract, Preview, Run

Constant Summary collapse

COMMANDS =
{
  'preview' => :Preview,
  'run' => :Run
}.freeze

Class Method Summary collapse

Class Method Details



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/buildkite/builder/commands.rb', line 30

def self.print_help
  puts "    \#{'SYNOPSIS'.bright}\n    \\t\#{'buildkite-builder'.bright} COMMAND [OPTIONS] [PIPELINE]\n\n    \\t\#{'To see available options for specific commands:'.color(:dimgray)}\n    \\t\#{'buildkite-builder'.bright} COMMAND --help\n\n    \#{'COMMANDS'.bright}\n  HELP\n  COMMANDS.each do |command, klass|\n    puts <<~HELP\n      \\t\#{command.bright}\n      \\t\#{const_get(klass).description.color(:dimgray)}\\n\n    HELP\n  end\nend\n"

.runObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/buildkite/builder/commands.rb', line 17

def self.run
  if ARGV.empty? || ARGV.first == '--help'
    return print_help
  end

  command = ARGV.shift
  unless (command_class = COMMANDS[command])
    raise "Invalid command: #{command}"
  end

  const_get(command_class).execute
end