Sha256: e6ca0c5369733f41604201ad26157a2189107ed73925ec4e21ddb52434d17edd

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Mwc
  module Utils
    # The helper to register command on thor
    module CommandRegistry
      # :nodoc:
      def self.included(base)
        base.extend ClassMethods
      end

      # :nodoc:
      module ClassMethods
        # Add command to thor
        #
        # @param command [Class] the command to add
        #
        # @since 0.1.0
        # @api private
        def add_command(command)
          return unless command.display?

          command.options.each { |args| method_option(*args) }
          register command,
                   command.name,
                   command.usage,
                   command.description
        end

        # Add subcommand to thor
        #
        # @param command [Class] the subcommand
        #
        # @since 0.1.0
        # @api private
        def add_subcommand(command)
          return unless command.display?

          desc command.usage, command.description
          subcommand command.name, command
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mwc-0.4.0 lib/mwc/utils/command_registry.rb
mwc-0.3.0 lib/mwc/utils/command_registry.rb
mwc-0.2.0 lib/mwc/utils/command_registry.rb