Sha256: e9fe2381a951ad14ae6742e9a7c897e990cae2fe6331aad69af0990639745a16

Contents?: true

Size: 897 Bytes

Versions: 6

Compression:

Stored size: 897 Bytes

Contents

# frozen_string_literal: true

require "core"

module Hanamismith
  module CLI
    # The main Command Line Interface (CLI) object.
    class Shell
      include Actions::Import[:config, :build, :specification, :logger]

      def initialize(parser: Parser.new, **)
        super(**)
        @parser = parser
      end

      def call arguments = Core::EMPTY_ARRAY
        act_on parser.call(arguments)
      rescue OptionParser::ParseError => error
        logger.error { error.message }
      end

      private

      attr_reader :parser

      def act_on configuration
        case configuration
          in action_build: true then build.call configuration
          in action_config: Symbol => action then config.call action
          in action_version: true then logger.info { specification.labeled_version }
          else logger.any { parser.to_s }
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hanamismith-0.9.0 lib/hanamismith/cli/shell.rb
hanamismith-0.8.0 lib/hanamismith/cli/shell.rb
hanamismith-0.7.0 lib/hanamismith/cli/shell.rb
hanamismith-0.6.0 lib/hanamismith/cli/shell.rb
hanamismith-0.5.0 lib/hanamismith/cli/shell.rb
hanamismith-0.4.0 lib/hanamismith/cli/shell.rb