Sha256: 1c62f070343a43c75015abd95288314302ff249a136d5cd8b2d757effb7ba5e6

Contents?: true

Size: 773 Bytes

Versions: 1

Compression:

Stored size: 773 Bytes

Contents

# frozen_string_literal: true

require_relative "cli/index"
require_relative "cli/create"
require_relative "cli/destroy"
require_relative "cli/bye"

require "tty-prompt"

module EcsAutoscalingScheduler
  class Cli
    COMMAND = {
      index: "index",
      create: "create",
      destroy: "destroy",
      bye: "bye",
    }

    def run
      case ask_command
      when COMMAND[:index]
        Index.new.run
      when COMMAND[:create]
        Create.new.run
      when COMMAND[:destroy]
        Destroy.new.run
      else
        Bye.new.run
      end
    end

    private
      def prompt
        @prompt ||= TTY::Prompt.new
      end

      def ask_command
        prompt.select("Which command do you want to do?", COMMAND.values, required: true)
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ecs_autoscaling_scheduler-0.1.0 lib/ecs_autoscaling_scheduler/cli.rb