Help option fixes

This commit is contained in:
Juan Ferrer 2022-04-04 21:14:04 +02:00
parent d7fd7546bb
commit 19e72112ea
3 changed files with 16 additions and 16 deletions

28
myvc.js
View File

@ -78,6 +78,8 @@ class MyVC {
} }
const allOpts = Object.assign({}, baseOpts); const allOpts = Object.assign({}, baseOpts);
if (command.localOpts)
for (const key in command.localOpts) { for (const key in command.localOpts) {
const baseValue = baseOpts[key]; const baseValue = baseOpts[key];
const cmdValue = command.localOpts[key]; const cmdValue = command.localOpts[key];
@ -388,21 +390,19 @@ class MyVC {
if (usage.description) if (usage.description)
console.log(`${'Description:'.gray} ${usage.description}`); console.log(`${'Description:'.gray} ${usage.description}`);
if (opts) { if (opts && opts.alias) {
console.log('Options:'.gray); const alias = opts.alias;
this.printOpts(opts, usage, 'alias'); const boolean = opts.boolean || [];
}
}
printOpts(opts, usage, group) { console.log('Options:'.gray);
const optGroup = opts[group]; for (const opt in alias) {
if (optGroup) const paramDescription = usage.params[opt] || '';
for (const opt in optGroup) { let longOpt = opt;
const paramDescription = usage.params[opt] || ''; if (boolean.indexOf(longOpt) === -1)
let longOpt = opt; longOpt += ` <string>`;
if (group !== 'boolean') longOpt += ` <string>`; longOpt = camelToSnake(longOpt).padEnd(22, ' ')
longOpt = camelToSnake(longOpt).padEnd(22, ' ') console.log(` -${alias[opt]}, --${longOpt} ${paramDescription}`);
console.log(` -${optGroup[opt]}, --${longOpt} ${paramDescription}`); }
} }
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "myvc", "name": "myvc",
"version": "1.3.10", "version": "1.3.11",
"author": "Verdnatura Levante SL", "author": "Verdnatura Levante SL",
"description": "MySQL Version Control", "description": "MySQL Version Control",
"license": "GPL-3.0", "license": "GPL-3.0",

View File

@ -8,6 +8,6 @@
"type": "git" "type": "git"
}, },
"dependencies": { "dependencies": {
"myvc": "^1.3.10" "myvc": "^1.3.11"
} }
} }