class GitlabClusterHelper::Runner

Public Class Methods

new(manager: GitlabClusterHelper::Manager.new, readline_class: Readline, output: $stdout) click to toggle source
# File lib/gitlab_cluster_helper/runner.rb, line 5
def initialize(manager: GitlabClusterHelper::Manager.new, readline_class: Readline, output: $stdout)
  @manager = manager
  @readline_class = readline_class
  @output = output
end

Public Instance Methods

start() click to toggle source
# File lib/gitlab_cluster_helper/runner.rb, line 11
def start
  print_help

  while line = @readline_class.readline('> ', true)
    if command = commands[line]
      command[:command].call
    end

    @output.puts Messages::GOODBYE && break if line == 'q'

    print_help
  end
end

Private Instance Methods

commands() click to toggle source
# File lib/gitlab_cluster_helper/runner.rb, line 27
def commands
  {
    'c' => { message: Messages::CREATE, command: method(:create) },
    'q' => { message: Messages::QUIT, command: @manager.method(:cleanup) },
  }
end
create() click to toggle source
# File lib/gitlab_cluster_helper/runner.rb, line 34
    def create
      cluster = @manager.create

      @output.puts <<~END
      Name: #{cluster.name}
      Api URL: #{cluster.api_url}
      Ca Certificate:
      #{cluster.ca_certificate}
      Token: #{cluster.token}
      END
    end
print_help() click to toggle source