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

Create a way to get a structured representation of a given .NET CLI command #46345

Open
baronfel opened this issue Jan 28, 2025 · 3 comments
Open
Assignees
Labels
cli-ux Issues and PRs that deal with the UX of the CLI (exit codes, log output, verbs/options, and so on) Feature Request

Comments

@baronfel
Copy link
Member

baronfel commented Jan 28, 2025

Is your feature request related to a problem? Please describe.

It can be useful for tools that are doing feature-probing of the .NET CLI to provide some structured representation of the CLI Command being invoked.

Describe the solution you'd like

This structured representation should provide access to

  • the names and aliases of the command (if any)
  • the options on the command
  • the arguments on the command
  • the subcommands on this command (recursively)

In this output, hidden items should be shown.

Additional context

The least grammar impacting way to do this would be a Directive, a la dotnet run [structure format=json], but there's space for some kind of global flag that could be used as well (dotnet run --dump-grammar?).

This was first requested in dotnet/aspire#7112 (comment).
NuGet experiences in DevKit also drive themselves based on the CLI capabilities and could make use of this.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-CLI untriaged Request triage from a team member labels Jan 28, 2025
@baronfel baronfel added cli-ux Issues and PRs that deal with the UX of the CLI (exit codes, log output, verbs/options, and so on) and removed untriaged Request triage from a team member Area-CLI labels Jan 28, 2025
@baronfel baronfel self-assigned this Feb 12, 2025
@MiYanni
Copy link
Member

MiYanni commented Feb 12, 2025

@baronfel Is this a dup of this? Which was a dup of this?

@baronfel
Copy link
Member Author

Hah! Yes it is, but mine is the best one :D

@KalleOlaviNiemitalo
Copy link
Contributor

In #41142 + #46717, dotnet test reads an environment variable or a configuration file and then decides whether to use a TestingPlatformCommand for Microsoft.Testing.Platform or DocumentedCommand for VSTest. Those do not support all the same options, so the "structured representation" would depend on which test runner the project uses. That is not a problem if the caller uses the output for command completion immediately, but becomes a problem if the caller translates the output to a command completion script and saves that for later use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli-ux Issues and PRs that deal with the UX of the CLI (exit codes, log output, verbs/options, and so on) Feature Request
Projects
None yet
Development

No branches or pull requests

3 participants