lib/alias.js
function aliasExpand(cmdmap){
  var cmds = {}
    , twei = require('../')
    , alias, apiGroup
    ;

  for(var key in cmdmap){
    alias = cmdmap[key];
    if(alias.alias){
      if(Array.isArray(alias.alias)){
        for(var i = 0, l = alias.alias.length; i < l; i++){
          cmds[alias.alias[i]] = cmdmap[key].cmd;
        }
      }else{
        cmds[alias.alias] = cmdmap[key].cmd;
      }
      cmds[key] = cmdmap[key].cmd;
      delete alias.alias;
    }else{
      cmds[key] = cmdmap[key].cmd || cmdmap[key];
    }
    
    if(alias.apis && typeof (apiGroup = twei.getApiGroup(alias.apis)) == 'object'){
      for(var apiName in apiGroup){
        if(!cmds[key + '.' + apiName]){
          cmds[key + '.' + apiName] = 'execute ' + alias.apis + '.' + apiName;
        }
      }
    }
  }
  //console.log(cmds);
  return cmds;
}
function aliasExpand(cmdmap){
  var cmds = {}
    , twei = require('../')
    , alias, apiGroup
    ;

  for(var key in cmdmap){
    alias = cmdmap[key];
    if(alias.alias){
      if(Array.isArray(alias.alias)){
        for(var i = 0, l = alias.alias.length; i < l; i++){
          cmds[alias.alias[i]] = cmdmap[key].cmd;
        }
      }else{
        cmds[alias.alias] = cmdmap[key].cmd;
      }
      cmds[key] = cmdmap[key].cmd;
      delete alias.alias;
    }else{
      cmds[key] = cmdmap[key].cmd || cmdmap[key];
    }
    
    if(alias.apis && typeof (apiGroup = twei.getApiGroup(alias.apis)) == 'object'){
      for(var apiName in apiGroup){
        if(!cmds[key + '.' + apiName]){
          cmds[key + '.' + apiName] = 'execute ' + alias.apis + '.' + apiName;
        }
      }
    }
  }
  //console.log(cmds);
  return cmds;
}
function aliasExpand ( cmdmap ) { var cmds = { } , twei = require ( '../' ) , alias , apiGroup ; for ( var key in cmdmap ) { alias = cmdmap [ key ] ; if ( alias . alias ) { if ( Array . isArray ( alias . alias ) ) { for ( var i = 0 , l = alias . alias . length ; i < l ; i ++ ) { cmds [ alias . alias [ i ] ] = cmdmap [ key ] . cmd ; } } else { cmds [ alias . alias ] = cmdmap [ key ] . cmd ; } cmds [ key ] = cmdmap [ key ] . cmd ; delete alias . alias ; } else { cmds [ key ] = cmdmap [ key ] . cmd || cmdmap [ key ] ; } if ( alias . apis && typeof ( apiGroup = twei . getApiGroup ( alias . apis ) ) == 'object' ) { for ( var apiName in apiGroup ) { if ( ! cmds [ key + '.' + apiName ] ) { cmds [ key + '.' + apiName ] = 'execute ' + alias . apis + '.' + apiName ; } } } } //console.log(cmds); return cmds ; }
restore alias to core command
@param {Object} cmdmap aliasmap
@return {Object} 返回完整的 名称:命令 对象
Example:
{
update: ''execute status.update''
, user: 'execute user.show'
, whois: 'execute user.show'
}
restore alias to core command