Module: Oc::Run

Defined in:
lib/system/run/run.rb,
lib/system/run/commands/ssh.rb,
lib/system/run/commands/info.rb,
lib/system/run/commands/sizes.rb,
lib/system/run/commands/domain.rb,
lib/system/run/commands/images.rb,
lib/system/run/commands/regions.rb,
lib/system/run/commands/droplets.rb

Defined Under Namespace

Classes: Base, Domain, Droplets, Images, Info, Regions, Sizes, Ssh

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#mainObject

Returns the value of attribute main.



4
5
6
# File 'lib/system/run/run.rb', line 4

def main
  @main
end

Class Method Details

.add(opts) ⇒ Object



13
14
15
# File 'lib/system/run/run.rb', line 13

def self.add(opts)
  commands[opts[:name]] = opts
end

.load_commandsObject



6
7
8
9
10
11
# File 'lib/system/run/run.rb', line 6

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



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/system/run/run.rb', line 17

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], o[:optional]].compact.flatten(1)
        c.option *option_data
        o[:arg] = Commander::Runner.switch_to_sym(Array(o[:switches]).last)
      end
      c.when_called do |args, options|
        object = opts[:class].new
        object.options = options
        run(object,opts[:method],args)
      end
    end
  end
end