Sha256: d276f26c0255cf5969a28ec7bb5d4b5b778c59c159952650a2d7eef90422f7eb

Contents?: true

Size: 1.24 KB

Versions: 10

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

module Buildkite
  module Builder
    module Commands
      using Rainbow
      COMMANDS = {
        'files' => :Files,
        'preview' => :Preview,
        'run' => :Run
      }.freeze

      autoload :Abstract, File.expand_path('commands/abstract', __dir__)
      COMMANDS.each do |command, klass|
        autoload klass, File.expand_path("commands/#{command}", __dir__)
      end

      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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
buildkite-builder-1.4.1 lib/buildkite/builder/commands.rb
buildkite-builder-1.4.0 lib/buildkite/builder/commands.rb
buildkite-builder-1.3.1 lib/buildkite/builder/commands.rb
buildkite-builder-1.3.0 lib/buildkite/builder/commands.rb
buildkite-builder-1.2.0 lib/buildkite/builder/commands.rb
buildkite-builder-1.1.0 lib/buildkite/builder/commands.rb
buildkite-builder-1.0.0 lib/buildkite/builder/commands.rb
buildkite-builder-1.0.0.beta.5 lib/buildkite/builder/commands.rb
buildkite-builder-1.0.0.beta.4 lib/buildkite/builder/commands.rb
buildkite-builder-1.0.0.beta.3 lib/buildkite/builder/commands.rb