Sha256: 99050fd53b77d524f59641ba6081f59b31ccfd23157f8a1877b003eacb995c11

Contents?: true

Size: 912 Bytes

Versions: 8

Compression:

Stored size: 912 Bytes

Contents

# frozen_string_literal: true

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

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

      def call arguments = []
        perform parser.call(arguments)
      rescue OptionParser::ParseError => error
        logger.error { error.message }
      end

      private

      attr_reader :parser

      def perform configuration
        case configuration
          in action_config: Symbol => action then config.call action
          in {action_insert: true} | {action_remove: true} then run.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

8 entries across 8 versions & 1 rubygems

Version Path
pragmater-12.0.0 lib/pragmater/cli/shell.rb
pragmater-11.5.0 lib/pragmater/cli/shell.rb
pragmater-11.4.0 lib/pragmater/cli/shell.rb
pragmater-11.3.0 lib/pragmater/cli/shell.rb
pragmater-11.2.0 lib/pragmater/cli/shell.rb
pragmater-11.1.0 lib/pragmater/cli/shell.rb
pragmater-11.0.1 lib/pragmater/cli/shell.rb
pragmater-11.0.0 lib/pragmater/cli/shell.rb