var childproc = require('child_process');
const util = require('util');
const exec = util.promisify(require('child_process').exec);

class ZhugeClient {
    constructor() {
        this.cmdGetPattern = "curl -G -X GET -H 'Authorization:Basic MTUwMTEyNTUyNDU6OTczY2RkMDc0MzgzNDhhZDkxNTM0ZjU3OTYzMmNjNmI=' '{url}'";
    }
    FetchGetCmd(subData, url) {
        var cmd = this.cmdGetPattern.replace(/\{url\}/g, url);
        console.log(cmd);
        return cmd;
    }
    async execGet(subData, url) {
        let cmd = this.FetchGetCmd(subData, url);
        console.log(cmd);
        var result = await exec(cmd);
        return result;
    }
}

module.exports = ZhugeClient;
// var x=new RestClient();
// x.execGet("","http://www.163.com").then(function(r){
//   console.log(r.stdout);
//   console.log(r.stderr);
// });
