Skip to content
Snippets Groups Projects
Verified Commit aec3d81c authored by orestis.malaspin's avatar orestis.malaspin
Browse files

minor correction

parent 31725ab7
No related branches found
No related tags found
No related merge requests found
Pipeline #29439 passed
...@@ -124,31 +124,29 @@ function generateCommandChain(cmd: Command | null): string { ...@@ -124,31 +124,29 @@ function generateCommandChain(cmd: Command | null): string {
return data.trimEnd() return data.trimEnd()
} }
function optionsToString(cmd: Command): string {
if (cmd.options.length == 0) {
return ''
}
return cmd.options.filter(opt => !opt.hidden).map(opt => {
return `${prefix} ${computeHeigth(cmd)} ${generateCommandChain(cmd)}' -a "--${opt.name()}" -d "${opt.description}"`
}).join('\n').concat('\n')
}
export function writeFishCompletion(root: Command, filename: string) { export function writeFishCompletion(root: Command, filename: string) {
const commands = flatten(root) const commands = flatten(root)
let data = fishFunction let data = fishFunction
// add commands and subcommands // add commands and subcommands
commands.forEach(cmd => { commands.forEach(cmd => {
if (isLeaf(cmd)) { data += optionsToString(cmd)
cmd.options.forEach(opt => { if (!isLeaf(cmd)) {
if (!opt.hidden) { data += cmd.commands.map(subCmd => {
data += `${prefix} ${computeHeigth(cmd)} ${generateCommandChain(cmd)}' -a "--${opt.name()}" -d "${opt.description}"\n` return `${prefix} ${computeHeigth(cmd)} ${generateCommandChain(cmd)}' -a ${subCmd.name()} -d "${subCmd.description()}"`
}).join('\n').concat('\n')
} }
}) })
}
cmd.commands.forEach(subCmd => {
data += `${prefix} ${computeHeigth(cmd)} ${generateCommandChain(cmd)}' -a ${subCmd.name()} -d "${subCmd.description()}"\n`
if (cmd.options.length > 0) {
cmd.options.forEach(opt => {
if (!opt.hidden) {
data += `${prefix} ${computeHeigth(cmd)} ${generateCommandChain(cmd)}' -a "--${opt.name()}" -d "${opt.description}"\n`
}
})
}
})
})
writeFileSync(filename, data); writeFileSync(filename, data);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment