blob: c1351908d083107d2cd8ae796854f61159d8fa4c [file] [log] [blame]
import nmo from './nmo.js';
import Promise from 'bluebird';
import {spawn as spawn} from 'child_process';
function getMainHelpText (cmds) {
return `
Usage:
nmo <command>
Available Commands:
${cmds}
Get help for a command:
nmo help <command>
nmo@${nmo.version}`;
}
export default help;
export const cli = helpCli;
function helpCli (cmd) {
return new Promise((resolve, reject) => {
if (!cmd || !nmo.commands[cmd]) {
help();
return resolve();
}
const path = `${__dirname}/../man/man1/nmo-${cmd}.1`;
const child = spawn('man', [path], {stdio: 'inherit'});
resolve(child);
});
}
function help () {
return new Promise((resolve, reject) => {
const cmds = Object.keys(nmo.commands).join(', ');
console.log(getMainHelpText(cmds));
resolve();
});
}