Sha256: 6844172d0e46f32ac658d6eb71879d149d7d59f98b339ad7cd0d99cae78d7063

Contents?: true

Size: 876 Bytes

Versions: 8

Compression:

Stored size: 876 Bytes

Contents

# frozen_string_literal: true

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

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

      def call arguments = []
        perform parser.call(arguments)
      rescue OptionParser::ParseError => error
        puts 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 then insert.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
tocer-15.0.0 lib/tocer/cli/shell.rb
tocer-14.5.0 lib/tocer/cli/shell.rb
tocer-14.4.0 lib/tocer/cli/shell.rb
tocer-14.3.0 lib/tocer/cli/shell.rb
tocer-14.2.0 lib/tocer/cli/shell.rb
tocer-14.1.0 lib/tocer/cli/shell.rb
tocer-14.0.1 lib/tocer/cli/shell.rb
tocer-14.0.0 lib/tocer/cli/shell.rb