Skip to content

Commit 37c20e2

Browse files
committed
fix: show built-in options in help output (#33)
1 parent b6055b8 commit 37c20e2

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

src/bargs.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,10 @@ const parseCore = (
860860
const version = detectVersionSync(options.version);
861861
if (version) {
862862
console.log(version);
863-
process.exit(0);
863+
} else {
864+
console.log('Version information not available');
864865
}
866+
process.exit(0);
865867
}
866868

867869
// Handle shell completion (when enabled)
@@ -1004,8 +1006,24 @@ const generateCommandHelpNew = (
10041006
*/
10051007
/* c8 ignore start -- only called from help paths that call process.exit() */
10061008
const generateHelpNew = (state: InternalCliState, theme: Theme): string => {
1007-
// Build options schema, adding --completion-script if completion is enabled
1009+
// Build options schema, adding built-in options
10081010
let options = state.globalParser?.__optionsSchema;
1011+
1012+
// Always add --help and --version (they're always available)
1013+
options = {
1014+
...options,
1015+
help: {
1016+
aliases: ['h'],
1017+
description: 'Show help information',
1018+
type: 'boolean' as const,
1019+
},
1020+
version: {
1021+
description: 'Show version number',
1022+
type: 'boolean' as const,
1023+
},
1024+
};
1025+
1026+
// Add --completion-script if completion is enabled
10091027
if (state.options.completion) {
10101028
options = {
10111029
...options,

0 commit comments

Comments
 (0)