Sha256: ba0770b390b3627a345e24fa15177f2a25c1c5d223c4d16555796924cbb2645a

Contents?: true

Size: 1006 Bytes

Versions: 14

Compression:

Stored size: 1006 Bytes

Contents

# frozen_string_literal: true

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, **dependencies
        super(**dependencies)
        @parser = parser
      end

      def call arguments = []
        perform parser.call(arguments)
      rescue OptionParser::ParseError, Milestoner::Error => 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_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

14 entries across 14 versions & 1 rubygems

Version Path
rubysmith-4.2.0 lib/rubysmith/cli/shell.rb
rubysmith-4.1.0 lib/rubysmith/cli/shell.rb
rubysmith-4.0.1 lib/rubysmith/cli/shell.rb
rubysmith-4.0.0 lib/rubysmith/cli/shell.rb
rubysmith-3.8.0 lib/rubysmith/cli/shell.rb
rubysmith-3.7.0 lib/rubysmith/cli/shell.rb
rubysmith-3.6.0 lib/rubysmith/cli/shell.rb
rubysmith-3.5.0 lib/rubysmith/cli/shell.rb
rubysmith-3.4.0 lib/rubysmith/cli/shell.rb
rubysmith-3.3.0 lib/rubysmith/cli/shell.rb
rubysmith-3.2.0 lib/rubysmith/cli/shell.rb
rubysmith-3.1.0 lib/rubysmith/cli/shell.rb
rubysmith-3.0.1 lib/rubysmith/cli/shell.rb
rubysmith-3.0.0 lib/rubysmith/cli/shell.rb