# File lib/rhc/commands.rb, line 130
    def self.to_commander(instance=Commander::Runner.instance)
      global_options.each{ |args| instance.global_option *args }
      commands.each_pair do |name, opts|
        instance.command name do |c|
          c.description = opts[:description]
          c.summary = opts[:summary]
          c.syntax = opts[:syntax]

          options_metadata = opts[:options]||[]
          options_metadata.each do |o|
            option_data = [o[:switches], o[:description]].flatten(1)
            c.option *option_data
            o[:arg] = Runner.switch_to_sym(o[:switches].last)
          end
          args_metadata = opts[:args] || []
          (args_metadata).each do |arg_meta|
            arg_switches = arg_meta[:switches]
            unless arg_switches.nil? or arg_switches.empty?
              arg_switches << arg_meta[:description]
              c.option *arg_switches
            end
          end

          c.when_called do |args, options|
            config = global_config_setup options
            cmd = opts[:class].new c
            cmd.options = options
            cmd.config = config
            filled_args = cmd.validate_args_and_options args_metadata, options_metadata, args
            needs_configuration! cmd, config
            cmd.send opts[:method], *filled_args
          end

          unless opts[:aliases].nil?
            opts[:aliases].each do |a, root_command|
              alias_cmd = a
              unless root_command
                # prepend the current resource
                alias_components = name.split(" ")
                alias_components[-1] = a
                alias_cmd = alias_components.join(' ')
              end
              instance.alias_command  "#{alias_cmd}", "#{name}""#{name}"
            end
          end
        end
      end
      self
    end