Sha256: fef8082a300fe56f3a11a7162068067bc480dc27fe3d52c320734b28840db85f

Contents?: true

Size: 968 Bytes

Versions: 2

Compression:

Stored size: 968 Bytes

Contents

# frozen_string_literal: true

require "core"

module Milestoner
  module CLI
    # The main Command Line Interface (CLI) object.
    class Shell
      include Actions::Import[:config, :publish, :status, :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 => 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_publish: true then publish.call configuration
          in action_status: true then status.call
          in action_version: true then logger.info { specification.labeled_version }
          else logger.any { parser.to_s }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
milestoner-15.2.2 lib/milestoner/cli/shell.rb
milestoner-15.2.1 lib/milestoner/cli/shell.rb