fix bug on exit code

This commit is contained in:
zkronos73 2022-02-24 13:20:18 +01:00
parent 7524bf8557
commit 5a09e51e84

@ -58,6 +58,7 @@ export default async function clProcessor(commands) {
for (let i=0; i<commands.length; i++) { for (let i=0; i<commands.length; i++) {
const cmd = commands[i]; const cmd = commands[i];
const m = calculateMatch(commands[i], cl); const m = calculateMatch(commands[i], cl);
let res;
if (m) { if (m) {
if ((argv.h) || (argv.help)) { if ((argv.h) || (argv.help)) {
helpCmd(cmd); helpCmd(cmd);
@ -66,16 +67,16 @@ export default async function clProcessor(commands) {
if (areParamsValid(cmd.cmd, m)) { if (areParamsValid(cmd.cmd, m)) {
if (cmd.options) { if (cmd.options) {
const options = getOptions(cmd.options); const options = getOptions(cmd.options);
await cmd.action(m, options); res = await cmd.action(m, options);
} else { } else {
await cmd.action(m, {}); res = await cmd.action(m, {});
} }
} else { } else {
if (m.length>0) console.log("Invalid number of parameters"); if (m.length>0) console.log("Invalid number of parameters");
helpCmd(cmd); helpCmd(cmd);
return 99; return 99;
} }
return; return res;
} }
} }
if (cl.length>0) console.log("Invalid command"); if (cl.length>0) console.log("Invalid command");