Module: Hole::Run
- Defined in:
- lib/system/run/run.rb,
lib/system/run/commands/server.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#main ⇒ Object
Returns the value of attribute main.
Class Method Summary collapse
- .add(opts) ⇒ Object
- .load_commands ⇒ Object
- .parse_command(ins = Commander::Runner::instance) ⇒ Object
Instance Attribute Details
#main ⇒ Object
Returns the value of attribute main.
8 9 10 |
# File 'lib/system/run/run.rb', line 8 def main @main end |
Class Method Details
.add(opts) ⇒ Object
17 18 19 |
# File 'lib/system/run/run.rb', line 17 def self.add(opts) commands[opts[:name]] = opts end |
.load_commands ⇒ Object
10 11 12 13 14 15 |
# File 'lib/system/run/run.rb', line 10 def self.load_commands Dir[File.join(File.dirname(__FILE__), "commands", "*.rb")].each do |file| require file end self end |
.parse_command(ins = Commander::Runner::instance) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/system/run/run.rb', line 21 def self.parse_command(ins = Commander::Runner::instance) commands.each_pair do |name, opts| name = Array(name) names = [name.reverse.join('-'), name.join(' ')] if name.length > 1 name = name.join(" ") ins.command name do |c| c.description = opts[:options][:description] c.summary = opts[:options][:summary] c.syntax = opts[:options][:syntax] ( = Array(opts[:options][:meta])).each do |o| option_data = [o[:switches], o[:type], o[:description]].compact.flatten(1) c.option *option_data o[:arg] = Commander::Runner.switch_to_sym(Array(o[:switches]).last) end c.when_called do |args, | object = opts[:class].new object. = run(object,opts[:method],args) end end end end |