Skip to content

Commit 23c097b

Browse files
committed
feat(help): show --completion-script in help when completion enabled
1 parent b073c1b commit 23c097b

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/bargs.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,18 @@ const generateCommandHelpNew = (
10041004
*/
10051005
/* c8 ignore start -- only called from help paths that call process.exit() */
10061006
const generateHelpNew = (state: InternalCliState, theme: Theme): string => {
1007+
// Build options schema, adding --completion-script if completion is enabled
1008+
let options = state.globalParser?.__optionsSchema;
1009+
if (state.options.completion) {
1010+
options = {
1011+
...options,
1012+
'completion-script': {
1013+
description: 'Output shell completion script (bash, zsh, fish)',
1014+
type: 'string' as const,
1015+
},
1016+
};
1017+
}
1018+
10071019
// Delegate to existing help generator with config including aliases
10081020
const config = {
10091021
commands: Object.fromEntries(
@@ -1016,7 +1028,7 @@ const generateHelpNew = (state: InternalCliState, theme: Theme): string => {
10161028
),
10171029
description: state.options.description,
10181030
name: state.name,
1019-
options: state.globalParser?.__optionsSchema,
1031+
options,
10201032
version: state.options.version,
10211033
};
10221034
return generateHelp(config as Parameters<typeof generateHelp>[0], theme);

0 commit comments

Comments
 (0)