dotnet / command-line-api

Command line parsing, invocation, and rendering of terminal output.
https://github.com/dotnet/command-line-api/wiki
MIT License
3.34k stars 375 forks source link

[Design] Is any syntax (like punctuation) is allowed for commands? #2401

Open KathleenDollard opened 2 months ago

KathleenDollard commented 2 months ago

Hyphens in command names would be allowed.

Do we want to do things like allowing --help to be a command?

KalleOlaviNiemitalo commented 2 months ago

Hyphens must be supported in subcommand names (dotnet build-server).

The root command name should allow dots too, for version numbers (myapp2.3).

KathleenDollard commented 2 months ago

@KalleOlaviNiemitalo Thanks! I updated the description a touch.

KalleOlaviNiemitalo commented 2 months ago

I don't see a pressing need for --help as a command. There is some precedent in curl --help all but I think this can be supported by making all an optional argument of the --help option. IIRC, GNU getopt_long parses an optional argument of a long option only if connected with an equals sign as in --help=all; if System.CommandLine is made to also behave this way, i.e. parse --help all as an option followed by an unrelated argument, then application developers should still be able to override this behavior by giving the --help option a custom parser that consumes the all token even if not connected.

KalleOlaviNiemitalo commented 2 months ago

There is the convention of a login shell getting an argv[0] that starts with a hyphen. For example, -bash. That should then be allowed in the root command name, too. But the .NET Runtime does not currently pass the string through to applications (https://github.com/dotnet/command-line-api/issues/2365, https://github.com/dotnet/runtime/issues/30212).