Sha256: 939e7b2101832822d949866872e7161cfd8c6150162741f2b384d4e29db6928a

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

module Metacrunch
  class Cli
    class CommandDefinition
      def initialize(command_class, description)
        @klass       = command_class
        @name        = nil
        @description = description
        @usage       = nil
        @options     = {}
      end

      def command_class(value = nil)
        @klass if value
        @klass
      end

      def name
        name = @klass.to_s.demodulize.underscore
        name.gsub!(/_command\Z/, "")
      end

      def usage(value = nil)
        @usage = value if value.present?
        @usage || name
      end

      def desc(value = nil)
        @description = value if value.present?
        @description
      end

      def option(name, options = {})
        @options[name] = options
      end

      def options
        @options
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
metacrunch-2.1.0 lib/metacrunch/cli/command_definition.rb