Sha256: a61f07e62621225cf05425238661821e89db5daa24428b8e9b033e5cdb95822d

Contents?: true

Size: 804 Bytes

Versions: 1

Compression:

Stored size: 804 Bytes

Contents

require "core"

<% namespace do %>
  module CLI
    # The main Command Line Interface (CLI) object.
    class Shell
      include Actions::Import[:config, :kernel, :logger, :specification]

      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 kernel.puts specification.labeled_version
          else kernel.puts parser.to_s
        end
      end
    end
  end
<% end %>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemsmith-19.8.0 lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/shell.rb.erb