Sha256: b7dc04bda91d525ee8c96b65433efd106191dadaf58626a73bf6d20ade97372b

Contents?: true

Size: 802 Bytes

Versions: 6

Compression:

Stored size: 802 Bytes

Contents

require "core"

<% namespace do %>
  module CLI
    # The main Command Line Interface (CLI) object.
    class Shell
      include Actions::Import[:config, :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
        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_version: true then logger.info { specification.labeled_version }
          else logger.any { parser.to_s }
        end
      end
    end
  end
<% end %>

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gemsmith-19.7.0 lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/shell.rb.erb
gemsmith-19.6.0 lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/shell.rb.erb
gemsmith-19.5.2 lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/shell.rb.erb
gemsmith-19.5.1 lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/shell.rb.erb
gemsmith-19.5.0 lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/shell.rb.erb
gemsmith-19.4.0 lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/shell.rb.erb