Sha256: 1330be2e6732192330f1d9d8c67f34d26daf1a6db9759ca1df4104073fea2a01

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 KB

Contents

require 'thor'

class Bora
  class CliBase < Thor
    # Fix for incorrect subcommand help. See https://github.com/erikhuda/thor/issues/261
    def self.banner(command, _namespace = nil, subcommand = false)
      subcommand = subcommand_prefix
      subcommand_str = subcommand ? " #{subcommand}" : ''
      "#{basename}#{subcommand_str} #{command.usage}"
    end

    def self.subcommand_prefix
      nil
    end

    no_commands do
      def stack(config_file, stack_name)
        region = options.region
        cfn_stack_name = options['cfn-stack-name']

        override_config = {}
        override_config['default_region'] = region if region
        override_config['cfn_stack_name'] = cfn_stack_name if cfn_stack_name

        bora = bora(config_file, override_config)
        stack = bora.stack(stack_name)
        unless stack
          STDERR.puts "Could not find stack #{stack_name}"
          exit(1)
        end
        stack
      end

      def bora(config_file, override_config = {})
        Bora.new(config_file_or_hash: config_file, override_config: override_config)
      end

      def params
        options.params ? Hash[options.params.map { |param| param.split('=', 2) }] : {}
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bora-1.7.4 lib/bora/cli_base.rb
bora-1.7.3 lib/bora/cli_base.rb
bora-1.7.2 lib/bora/cli_base.rb
bora-1.7.1 lib/bora/cli_base.rb
bora-1.7.0 lib/bora/cli_base.rb