Class: Escort::Setup::Dsl::Command
- Inherits:
-
Object
- Object
- Escort::Setup::Dsl::Command
- Defined in:
- lib/escort/setup/dsl/command.rb
Direct Known Subclasses
Instance Method Summary collapse
- #action(&block) ⇒ Object
- #command(name, options = {}, &block) ⇒ Object
- #description(description) ⇒ Object
-
#initialize(name, options = {}, &block) ⇒ Command
constructor
A new instance of Command.
- #options(&block) ⇒ Object
- #requires_arguments(boolean = true) ⇒ Object
- #summary(summary) ⇒ Object
Constructor Details
#initialize(name, options = {}, &block) ⇒ Command
Returns a new instance of Command.
5 6 7 8 9 10 11 12 13 |
# File 'lib/escort/setup/dsl/command.rb', line 5 def initialize(name, = {}, &block) reset(name) @description = [:description] || [:desc] || "" @aliases = [[:aliases] || []].flatten @requires_arguments ||= [:requires_arguments] block.call(self) if block_given? rescue => e raise Escort::ClientError.new("Problem with syntax of command '#{@name}' configuration", e) end |
Instance Method Details
#action(&block) ⇒ Object
19 20 21 |
# File 'lib/escort/setup/dsl/command.rb', line 19 def action(&block) Action.action(@name, @action, &block) end |
#command(name, options = {}, &block) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/escort/setup/dsl/command.rb', line 23 def command(name, = {}, &block) [:requires_arguments] = @requires_arguments command = Command.new(name.to_sym, , &block) aliases = [[:aliases] || []].flatten + [name] aliases.each do |name| @commands[name.to_sym] = command end end |
#description(description) ⇒ Object
44 45 46 |
# File 'lib/escort/setup/dsl/command.rb', line 44 def description(description) @description = description end |
#options(&block) ⇒ Object
15 16 17 |
# File 'lib/escort/setup/dsl/command.rb', line 15 def (&block) Options.(@name, @options, &block) end |
#requires_arguments(boolean = true) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/escort/setup/dsl/command.rb', line 32 def requires_arguments(boolean = true) raise Escort::ClientError.new("Parameter to 'requires_arguments' must be a boolean") unless [true, false].include?(boolean) @requires_arguments = boolean @commands.each do |command| command.requires_arguments(boolean) end end |
#summary(summary) ⇒ Object
40 41 42 |
# File 'lib/escort/setup/dsl/command.rb', line 40 def summary(summary) @summary = summary end |