-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
In 12.1.0, ---gnu-style-hidden-option was parsed as GnuStyleHiddenOption, but due to the changes in #2270, 13.0.0 now throws an error: Error: invalid Option flags: '---gnu-style-hidden-option'.
import { Command, Option } from "@commander-js/extra-typings";
const program = new Command();
program
.addOption(new Option("---gnu-style-hidden-option").hideHelp().default(false))
.action((opts) => {
console.log(opts.GnuStyleHiddenOption);
// 12.1.0: true or false
// 13.0.0: Error: invalid Option flags: '---gnu-style-hidden-option'
// N.B. @commander-js/extra-typings correctly infers the type of opts as { GnuStyleHiddenOption: boolean; }
// (even with @commander-js/extra-typings 13.0.0)
})
.parse();
/*
$ node /src/program_a/a.js ---gnu-style-hidden-option
/src/program_a/node_modules/commander/lib/option.js:342
throw new Error(`invalid Option flags: '${flags}'`);
^
Error: invalid Option flags: '---gnu-style-hidden-option'
at splitOptionFlags (/src/program_a/node_modules/commander/lib/option.js:342:11)
at new Option (/src/program_a/node_modules/commander/lib/option.js:20:25)
at file:///src/program_a/a.js:10:16
at ModuleJob.run (node:internal/modules/esm/module_job:271:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)
Node.js v22.12.0
*/Additional context
In GNU programs, triple-hyphen options are used as hidden debugging options that do not appear in the program --help output. (As far as I know, this is not documented anywhere and seems to be a convention within the GNU project. I think it existed in projects other than coreutils, but I'm not sure.)
stty ---debughttps://github.com/coreutils/coreutils/blob/v9.2/src/stty.c#L495 (since coreutils 9.2)tail ---disable-inotify -F a.txthttps://github.com/coreutils/coreutils/blob/v9.2/src/tail.c#L240 (since coreutils 7.6)
(I understand this is an unsupported usage, so I think this breaking change is valid. Feel free to close this issue. I just wanted to let you know that this unusual usage existed.)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels