Sha256: 9cfb8bf9ec16595eea18ea943d60d7dfa977c8bd8e49617695b7a1c4c9db10fa

Contents?: true

Size: 1011 Bytes

Versions: 4

Compression:

Stored size: 1011 Bytes

Contents

# frozen_string_literal: true

require "core"
require "milestoner"

module Rubysmith
  module CLI
    # The main Command Line Interface (CLI) object.
    class Shell
      include Actions::Import[:config, :build, :publish, :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, Milestoner::Error => error
        logger.error { error.message }
      end

      private

      attr_reader :parser

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubysmith-4.7.0 lib/rubysmith/cli/shell.rb
rubysmith-4.6.1 lib/rubysmith/cli/shell.rb
rubysmith-4.6.0 lib/rubysmith/cli/shell.rb
rubysmith-4.5.0 lib/rubysmith/cli/shell.rb