command-line-api icon indicating copy to clipboard operation
command-line-api copied to clipboard

Apply help to all symbols in the CLI declaration

Open KathleenDollard opened this issue 1 year ago • 2 comments

We are currently planning to remove global options. We think they are rarely used and add complexity to the parser.

Initialize for the subsystems gives us a great place to put the help option on every symbol in the tree. Altering HelpSubsystem.Initialize to add it across the tree, not just to the root. Also, tests are needed.

Note: This assumes that no other subsystem will add a command that will need help. If there is an order dependency here, we assume the CLI author will be aware of it and can use custom ordering by overriding Pipeline and updating InitializeSubsystems.

KathleenDollard avatar Mar 07 '24 12:03 KathleenDollard

Re global options: I made a command-line tool colorize its error and warning messages by default, but added a --no-color option to disable this. If global options are removed, I don't see how to make --no-color apply to parse errors (e.g. unrecognized subcommand). I suppose the NO_COLOR environment variable will have to be used instead.

KalleOlaviNiemitalo avatar Mar 07 '24 14:03 KalleOlaviNiemitalo

The plan is a utility method that would add the option to all of your tree.

Would there be issues with that approach for you? Definitely a good example of the need to have an option on all commands of a CLI.

KathleenDollard avatar Apr 05 '24 12:04 KathleenDollard