var dnspod=require('dnspod');
var config=require('./config.json');
if (!(process.argv[2] && process.argv[3]))
{
  console.log('使用方式 ：nodejs querySubdomian.js 域名 记录名');
  console.log('例如 ：nodejs querySubdomian.js jarln.net www');
  return;
}
var domain=process.argv[2];
var record=process.argv[3];
new dnspod.domainId(domain,config.username,config.password,function(id,request){
  if (id){
    console.log(domain+'域名ID:'+id);
    new dnspod.recordlist({domain_id:id,sub_domain:record,length:1},config.username,config.password,function(obj,request){
      if (request.code==1 && obj[record])
      {
	console.log(record+'.'+domain+'记录ID:'+obj[record]);
	return;
      }
      console.log('无法找到记录信息,错误号:'+request.code);
    });
    return; 
  }
  console.log('无法找到域名信息,错误号:'+request.code);
}); 
