Module: Vop::CommandSyntax
- Defined in:
- lib/vop/syntax/command_syntax.rb
Instance Method Summary collapse
- #allows_extra ⇒ Object
- #block_param(name = "block", options = {}) ⇒ Object
- #block_param!(name = "block", options = {}) ⇒ Object
- #contribute(options, &block) ⇒ Object
- #description(s) ⇒ Object
- #dont_log ⇒ Object
- #invalidate(&block) ⇒ Object
- #param(name, options = {}, more_options = {}) ⇒ Object
- #param!(name, options = {}, more_options = {}) ⇒ Object
- #read_only ⇒ Object
- #run(&block) ⇒ Object
- #show(options = {}) ⇒ Object
Instance Method Details
#allows_extra ⇒ Object
58 59 60 |
# File 'lib/vop/syntax/command_syntax.rb', line 58 def allows_extra @command.allows_extra = true end |
#block_param(name = "block", options = {}) ⇒ Object
43 44 45 46 |
# File 'lib/vop/syntax/command_syntax.rb', line 43 def block_param(name = "block", = {}) .merge! block: true param(name, ) end |
#block_param!(name = "block", options = {}) ⇒ Object
48 49 50 51 52 |
# File 'lib/vop/syntax/command_syntax.rb', line 48 def block_param!(name = "block", = {}) = () .merge! mandatory: true block_param(name, ) end |
#contribute(options, &block) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/vop/syntax/command_syntax.rb', line 74 def contribute(, &block) @op.register_contributor( command_name: [:to] || @command.short_name, contributor: @command.name ) @command.block = block end |
#description(s) ⇒ Object
5 6 7 |
# File 'lib/vop/syntax/command_syntax.rb', line 5 def description(s) @command.description = s end |
#dont_log ⇒ Object
62 63 64 |
# File 'lib/vop/syntax/command_syntax.rb', line 62 def dont_log @command.dont_log = true end |
#invalidate(&block) ⇒ Object
82 83 84 |
# File 'lib/vop/syntax/command_syntax.rb', line 82 def invalidate(&block) @command.invalidation_block = block end |
#param(name, options = {}, more_options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vop/syntax/command_syntax.rb', line 13 def param(name, = {}, = {}) = ().merge() if name.is_a? Symbol key = "name" # default for select_machine entity = @op.entities.values.select { |x| x.short_name == name.to_s }.first if entity.nil? raise "entity #{name.to_s} defined as param in #{@command.name} not found" else key = entity.key end [:entity] = true [:lookup] = lambda do list_command_name = name.to_s.carefully_pluralize the_list = @op.execute(list_command_name, {}) the_list.map(&key.to_sym) end name = name.to_s end @command.add_param(name, ) end |
#param!(name, options = {}, more_options = {}) ⇒ Object
37 38 39 40 41 |
# File 'lib/vop/syntax/command_syntax.rb', line 37 def param!(name, = {}, = {}) = ().merge() .merge! mandatory: true param(name, ) end |
#read_only ⇒ Object
54 55 56 |
# File 'lib/vop/syntax/command_syntax.rb', line 54 def read_only @command.read_only = true end |
#run(&block) ⇒ Object
9 10 11 |
# File 'lib/vop/syntax/command_syntax.rb', line 9 def run(&block) @command.block = block end |
#show(options = {}) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/vop/syntax/command_syntax.rb', line 66 def show( = {}) @command.[:columns] = .delete(:columns) @command.[:display_type] = .delete(:display_type) @command.[:sort] = .delete(:sort) raise "unknown keyword #{.keys.first}" if .keys.length > 0 end |