vodafone-station-cli
Version:
Access your Vodafone Station from the comfort of the command line.
56 lines (55 loc) • 2.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const core_1 = require("@oclif/core");
const base_command_1 = tslib_1.__importStar(require("../base-command"));
const docsis_diagnose_1 = tslib_1.__importDefault(require("../modem/docsis-diagnose"));
const printer_1 = require("../modem/printer");
const web_diagnose_1 = require("../modem/web-diagnose");
const docsis_1 = require("./docsis");
class Diagnose extends base_command_1.default {
static description = 'Diagnose the quality of the docsis connection.';
static examples = [
'$ vodafone-station-cli diagnose',
'$ vodafone-station-cli diagnose --ip 192.168.100.1',
];
static flags = {
ip: (0, base_command_1.ipFlag)(),
password: core_1.Flags.string({
char: 'p',
description: 'router/modem password',
}),
web: core_1.Flags.boolean({
char: 'w',
description: 'review the docsis values in a webapp',
}),
};
async run() {
const { flags } = await this.parse(Diagnose);
const password = flags.password ?? process.env.VODAFONE_ROUTER_PASSWORD;
if (!password || password === '') {
this.log('You must provide a password either using -p or by setting the environment variable VODAFONE_ROUTER_PASSWORD');
this.exit();
}
const discoveryOptions = {
ip: flags.ip,
};
try {
const docsisStatus = await (0, docsis_1.getDocsisStatus)(password, this.logger, discoveryOptions);
const diagnoser = new docsis_diagnose_1.default(docsisStatus);
const tablePrinter = new printer_1.TablePrinter(docsisStatus);
this.log(tablePrinter.print());
if (diagnoser.hasDeviations()) {
this.logger.warn('Docsis connection connection quality deviation found!');
}
if (flags.web) {
this.log(`Review your docsis state online -> ${(0, web_diagnose_1.webDiagnoseLink)(docsisStatus)}`);
}
this.log(diagnoser.printDeviationsConsole());
}
catch (error) {
this.error(error, { message: 'Something went wrong' });
}
}
}
exports.default = Diagnose;