Module: Relish::Command::Dsl

Included in:
Base
Defined in:
lib/relish/commands/dsl.rb,
lib/relish/commands/dsl/option.rb,
lib/relish/commands/dsl/command.rb,
lib/relish/commands/dsl/help_text.rb,
lib/relish/commands/dsl/context_class.rb

Defined Under Namespace

Modules: ContextClass Classes: Command, HelpText, Option

Instance Method Summary collapse

Instance Method Details

#command(arg, &block) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/relish/commands/dsl.rb', line 23

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

#desc(*text) ⇒ Object



19
20
21
# File 'lib/relish/commands/dsl.rb', line 19

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

#option(name, options = {}) ⇒ Object



10
11
12
13
# File 'lib/relish/commands/dsl.rb', line 10

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

#usage(text) ⇒ Object



15
16
17
# File 'lib/relish/commands/dsl.rb', line 15

def usage(text)
  HelpText.next_usage = text
end