Skip to content

[Breaking] Remove CommandResult #2367

Closed
@KathleenDollard

Description

@KathleenDollard

ParseResult is created at the end of parsing to hold the results. It does not contain any information used by parsing and is a prime candidate holding the ValueResults, which can be held sparsely with the default value for the type supplied when there is no value entered (default values are handled in the ValueSubsystem, not during parsing).

ArgumentResult and OptionResult are important to parsing and we want to minimize risk changing them. We are adding a ValueResult, because we think CLI authors rarely care where a value came from. When they do, the symbol will be available.

The future role of CommandResult is unclear. It appears is unnecessary for retrieving values, and the symbol tree would be available when the shape is of interest.

Thus, the plan is to remove CommandResult from the public API.

Please suggest additional known scenarios we need to consider.

Known scenarios that will need alternatives

Please suggest additional known scenarios we need to consider and any issues with the proposed solutions.

Sibling command default values

If the default for a sibling command's argument or option is needed, that would now come via the ValueSubsystem. Only type defaults are provided by the core parser layer and the ParseResult.

If needed, we could expose a SymbolByName method on configuration/parser/rootcommand, possibly with proximity semantics.

Retrieving values from different options/arguments on a command and a command ancestor with the same name by name

This scenario seems unusual, although not pathological.

Imagine a case where the root command and child commands have different options or arguments that have the same name, and the CLI author needs to retrieve more than one.

Today and in the future the CLI author can retrieve each value via its symbol reference.

Today, the CLI author can retrieve the leaf-most result by name and ask for its parent, search the CommandResult.Children and retrieve the ancestor value by name.

In the future, the CLI author will need to retrieve the symbol from the tree and search via symbol.

If we hear there is more need of this, we can provide helper methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions