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

`whatif`

Open KathleenDollard opened this issue 1 year ago • 1 comments

Consider an optional subsystem in the Invocation phase that allows a standard whatif mechanism.

  • A default option, similar to the help option added during the initialization step
  • Annotations (instance, not annotations) that provide
    • Delegate for custom output
  • A default implementation that on syntactic (core parser) errors:
    • Displays errors and no further information
  • The default implementation on core parser success:
    • Lists the command with its parent commands
    • Outputs options and arguments with the parsed values
    • Displays all output to that point
    • Displays all validation errors
  • Displays output is via a text writer, so that future enhancement to provide JSON output is accommodated

The expected usage is to replace diagramming where a simple understanding and confirmation of the parse result is needed. This can be important to CLI users and CLI authors. It may also be useful in tests, which is why a machine friendly output like JSON may be helpful.

Diagramming is still important to understand nuances of why parsing fails when it does not work as expected.

Proposed sample output:

ApplicationName.exe

Command: 
   Grandparent parent command

Arguments:
   Arg1: arg1 value
   Arg2: arg2 value

Options:
   Option1: value
   Option2: 41             Error: 41 is not the correct value

This subsystem could either be part of the standard Powderhouse subsystems or a separate package.

KathleenDollard avatar Jul 16 '24 10:07 KathleenDollard

Whatif there finally was a release?

Balkoth avatar Jul 17 '24 16:07 Balkoth