Sha256: ea5cf560c4a3adbdb77c1f014bd75fa8a90c2abfb8ad4a5ea24314bcec8fa22a

Contents?: true

Size: 828 Bytes

Versions: 13

Compression:

Stored size: 828 Bytes

Contents

require 'relish/commands/dsl/context_class'
require 'relish/commands/dsl/option'
require 'relish/commands/dsl/command'
require 'relish/commands/dsl/help_text'

module Relish
  module Command
    module Dsl

      def option(name, options = {})
        Option.new(self).define(name, options)
        Option.names << name.to_s
      end

      def usage(text)
        HelpText.next_usage = text
      end

      def desc(*text)
        HelpText.next_description = text.join("\n")
      end

      def command(arg, &block)
        case arg
        when Hash
          name, alias_target = arg.to_a.flatten
          block = lambda { self.send(alias_target) }
        when Symbol
          name = arg
        else
          raise ArgumentError
        end

        Command.new(self).define(name, &block)
      end

    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
relish-0.7.1 lib/relish/commands/dsl.rb
relish-0.7 lib/relish/commands/dsl.rb
relish-0.6 lib/relish/commands/dsl.rb
relish-0.5.3 lib/relish/commands/dsl.rb
relish-0.5.2 lib/relish/commands/dsl.rb
relish-0.5.1 lib/relish/commands/dsl.rb
relish-0.5.0 lib/relish/commands/dsl.rb
relish-0.4.0 lib/relish/commands/dsl.rb
relish-0.3.0 lib/relish/commands/dsl.rb
relish-0.3.0.pre lib/relish/commands/dsl.rb
relish-0.2.3 lib/relish/commands/dsl.rb
relish-0.2.2 lib/relish/commands/dsl.rb
relish-0.2.1 lib/relish/commands/dsl.rb