module Idcf::Cli::Controller::Extend::Command

command

Attributes

public_commands[R]

Public Instance Methods

desc(usage, description, options = {}) click to toggle source
Calls superclass method
# File lib/idcf/cli/controller/extend/command.rb, line 53
def desc(usage, description, options = {})
  super(usage, description, options)
  @public_commands ||= []
  cmd = usage.split(' ').shift
  @public_commands << cmd unless @public_commands.include?(cmd)
end
register_method_option!(values) click to toggle source

regist method option

@param values [Hash] name => desc

# File lib/idcf/cli/controller/extend/command.rb, line 42
def register_method_option!(values)
  return nil if values.nil?
  values.each do |opn, op|
    option = {}
    op.each do |ok, ov|
      option[ok.to_sym] = ov
    end
    method_option opn, option
  end
end
register_module_method!(name, cls) click to toggle source

register module mothod

@param name [String] command_name @param cls [Idcf::Cli::Service::Base]

# File lib/idcf/cli/controller/extend/command.rb, line 31
def register_module_method!(name, cls)
  register_method_option! cls.options
  desc "#{name} #{cls.make_param_s}", cls.description
  define_method name.to_sym do |*args|
    execute(__method__, *args)
  end
end
subcommand_structure() click to toggle source
Calls superclass method
# File lib/idcf/cli/controller/extend/command.rb, line 60
def subcommand_structure
  result = super
  list = @public_commands
  list.concat(superclass.public_commands) if superclass.respond_to?(:public_commands)
  list.each do |cmd|
    result[cmd] = nil unless result.key?(cmd)
  end
  result
end