Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for signalling the end of options #2433

Closed
PonchoPowers opened this issue May 31, 2024 · 2 comments
Closed

Add support for signalling the end of options #2433

PonchoPowers opened this issue May 31, 2024 · 2 comments

Comments

@PonchoPowers
Copy link

PonchoPowers commented May 31, 2024

Support needs to be added for an option terminator to allow common *nix commands to be parsed correctly.

The following is an example of calling the node command in Windows.

node -h

Usage: node [options] [ script.js ] [arguments]
node inspect [options] [ script.js | host:port ] [arguments]

Options:
- script read from stdin (default if no file name is provided, interactive mode if a tty)
-- indicate the end of node options

The snippet is cut short, to highlight the use of "--".

The following command shows why this is important...
node --check -- --loader

The node command would perform a syntax check on the --loader file without executing it.

Such an implementation is common and widely supported in *nix environments, yet some node commands can't correctly be parsed with the current API.

@elgonzo
Copy link
Contributor

elgonzo commented May 31, 2024

System.CommandLine already does support the Posix -- end-of-options delimiter. Anything after the -- will be treated as ordinary argument values.

@PonchoPowers
Copy link
Author

Yup sorry can see where it is defined now...

CliToken DoubleDash() => new("--", CliTokenType.DoubleDash, default, i);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants