Class: Escort::Setup::Dsl::Command
- Inherits:
-
Object
- Object
- Escort::Setup::Dsl::Command
- Defined in:
- lib/escort/setup/dsl/command.rb
Instance Method Summary collapse
- #action(&block) ⇒ Object
- #command(name, options = {}, &block) ⇒ Object
- #conflicting_options(*command_names) ⇒ 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 14 |
# File 'lib/escort/setup/dsl/command.rb', line 5 def initialize(name, = {}, &block) reset(name) @name = 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
20 21 22 |
# File 'lib/escort/setup/dsl/command.rb', line 20 def action(&block) Action.action(@name, @action, &block) end |
#command(name, options = {}, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/escort/setup/dsl/command.rb', line 24 def command(name, = {}, &block) raise Escort::ClientError.new("Parameter to 'requires_arguments' must be a boolean") unless [true, false].include?(boolean) [: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 |
#conflicting_options(*command_names) ⇒ Object
42 43 44 |
# File 'lib/escort/setup/dsl/command.rb', line 42 def (*command_names) raise Escort::ClientError.new("This interface for specifying conflicting options is no longer supported, please use 'opts.conflict' in the options block") end |
#description(description) ⇒ Object
50 51 52 |
# File 'lib/escort/setup/dsl/command.rb', line 50 def description(description) @description = description end |
#options(&block) ⇒ Object
16 17 18 |
# File 'lib/escort/setup/dsl/command.rb', line 16 def (&block) Options.(@name, @options, &block) end |
#requires_arguments(boolean = true) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/escort/setup/dsl/command.rb', line 34 def requires_arguments(boolean = true) #TODO raise a client error if the value is anything besides true or false @requires_arguments = boolean @commands.each do |command| command.requires_arguments(boolean) end end |
#summary(summary) ⇒ Object
46 47 48 |
# File 'lib/escort/setup/dsl/command.rb', line 46 def summary(summary) @summary = summary end |