UNPKG

ddnsman

Version:
50 lines (49 loc) 1.81 kB
#!/usr/bin/env node "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const child_process_1 = require("child_process"); const commander_1 = __importDefault(require("commander")); const path_1 = __importDefault(require("path")); const CommandExec_1 = require("../CommandExec"); const ipc_1 = require("../lib/ipc"); const util_1 = require("../lib/util"); // tslint:disable-next-line:no-var-requires const pkg = require('../../package.json'); commander_1.default.version(pkg.version); ipc_1.pingDaemon().then((started) => { if (!started) { child_process_1.fork(path_1.default.resolve(__dirname, '../lib/daemon')); } }); commander_1.default .command('start') .description('start DDNS') .option('--name <name>', 'Name') .option('-d --domainName <domain>', 'Domain *required') .option('-s --subdomain <subdomain>', 'Sub domain *required') .option('-t --login-token <token>', 'Login token, format:<Id,Token> *required') .action((options) => { util_1.logger.info('start with %o', options); const exec = new CommandExec_1.CommandExec(); exec.start(options.subdomain, options.domainName, options.loginToken, options.name); }); commander_1.default .command('stop <name>|all') .description('Stop DDNS with id') .action((name) => { util_1.logger.info('stop ' + name); const exec = new CommandExec_1.CommandExec(); exec.stop(name); }); commander_1.default .command('ls') .description('status of ddns') .action(() => { util_1.logger.info('list'); const exec = new CommandExec_1.CommandExec(); exec.list(); }); commander_1.default.parse(process.argv);