-
Notifications
You must be signed in to change notification settings - Fork 6k
System.CommandLine docs update #46594
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
base: main
Are you sure you want to change the base?
Conversation
…symbols and naming
… briefly mention features that are not expected to be used frequently like Recursive or Hidden symbols rename "Help Customization" to just "Help" and move "HelpOption" description there
…hat does not use invocation at all, then use help to explain what invocation is and what it provides
…, exposing mutable collections, default value changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding all these docs!
docs/standard/commandline/syntax.md
Outdated
|
||
Arguments can have expected types, and `System.CommandLine` displays an error message if an argument can't be parsed into the expected type. For example, the following command errors because "silent" isn't one of the valid values for `--verbosity`: | ||
## Parse Errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Parse Errors | |
## Parse errors |
docs/standard/commandline/syntax.md
Outdated
@@ -139,18 +170,16 @@ dotnet add package System.CommandLine --prerelease --no-restore --source https:/ | |||
dotnet add package System.CommandLine --source https://api.nuget.org/v3/index.json --no-restore --prerelease | |||
``` | |||
|
|||
When there are multiple arguments, the order does matter. The following commands are not necessarily equivalent: | |||
When there are multiple arguments, the order does matter. The following commands are not equivalent, they differ in the order of the values, which could lead to different results: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When there are multiple arguments, the order does matter. The following commands are not equivalent, they differ in the order of the values, which could lead to different results: | |
When there are multiple arguments, the order does matter. The following commands are not equivalent; they differ in the order of the values, which could lead to different results: |
docs/standard/commandline/syntax.md
Outdated
@@ -170,7 +199,11 @@ dotnet publish --ou ./publish | |||
dotnet publish --o ./publish | |||
``` | |||
|
|||
`System.CommandLine` doesn't support automatic aliases. | |||
`System.CommandLine` doesn't support automatic aliases, each alias needs to be specified in explicit way. Both commands and options expose `Aliases` property, but `Option` has a constructor that accepts aliases as parameters, so you can define an option with multiple aliases in a single line: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`System.CommandLine` doesn't support automatic aliases, each alias needs to be specified in explicit way. Both commands and options expose `Aliases` property, but `Option` has a constructor that accepts aliases as parameters, so you can define an option with multiple aliases in a single line: | |
`System.CommandLine` doesn't support automatic aliases. Each alias must be specified explicitly. Both commands and options expose an `Aliases` property. `Option` has a constructor that accepts aliases as parameters, so you can define an option with multiple aliases in a single line: |
docs/standard/commandline/syntax.md
Outdated
|
||
Both users and developers may find it useful to see how an app will interpret a given input. One of the default features of a `System.CommandLine` app is the `[parse]` directive, which lets you preview the result of parsing command input. For example: | ||
Both users and developers may find it useful to see how an app will interpret a given input. One of the default features of a `System.CommandLine` app is the `[diagram]` directive, which lets you preview the result of parsing command input. For example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both users and developers may find it useful to see how an app will interpret a given input. One of the default features of a `System.CommandLine` app is the `[diagram]` directive, which lets you preview the result of parsing command input. For example: | |
Both users and developers might find it useful to see how an app will interpret a given input. One of the default features of a `System.CommandLine` app is the `[diagram]` directive, which lets you preview the result of parsing command input. For example: |
@@ -28,7 +28,7 @@ For other command-line apps built on `System.CommandLine`: | |||
|
|||
* Install the [`dotnet-suggest`](https://nuget.org/packages/dotnet-suggest) global tool. | |||
|
|||
* Add the appropriate shim script to your shell profile. You may have to create a shell profile file. The shim script forwards completion requests from your shell to the `dotnet-suggest` tool, which delegates to the appropriate `System.CommandLine`-based app. | |||
* Add the appropriate shim script to your shell profile. You may need to create a shell profile file. The shim script forwards completion requests from your shell to the `dotnet-suggest` tool, which delegates them to the appropriate `System.CommandLine`-based app. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Add the appropriate shim script to your shell profile. You may need to create a shell profile file. The shim script forwards completion requests from your shell to the `dotnet-suggest` tool, which delegates them to the appropriate `System.CommandLine`-based app. | |
* Add the appropriate shim script to your shell profile. You might need to create a shell profile file. The shim script forwards completion requests from your shell to the `dotnet-suggest` tool, which delegates them to the appropriate `System.CommandLine`-based app. |
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Co-authored-by: Jon Sequeira <jonsequeira@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really awesome to see some traction in this area, thanks you! Here are some improvements I found.
--- | ||
title: How to configure the parser in System.CommandLine | ||
description: "Learn how to configure the parser in System.CommandLine." | ||
ms.date: 16/06/2025 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dates are MM/DD/YYYY
@@ -0,0 +1,330 @@ | |||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't name this file the version of the package, a new version means that a redirect has to be created and a file renamed. We also have a standard issue template for a "breaking change" doc, which we can use AI automation to generate details for. This article feels a little more like a "migration from beta 4 to beta 5" and would eventually go away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great feedback! migration-guide-2.0.0-beta5.md
perhaps?
- "command line interface" | ||
- "command line" | ||
- "System.CommandLine" | ||
ms.topic: how-to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a how to, I would leave it blank for now.
ms.topic: how-to |
|
||
Every <xref:System.CommandLine.ParseResult> instance has a <xref:System.CommandLine.ParseResult.Configuration> property that returns the configuration used for parsing. | ||
|
||
## Standard output and error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This article also isn't really a how to in the traditional sense. It just sort of plops a single snippet of code down and has some sub sections on what I assume are parameter options? But these descriptions don't really explain the options. For example, what does ResponseFileTokenReplacer actually do? Why would someone use it?
I would rewrite this to have a better "how to" approach:
- Configure the parser to do X
- Configure the parser to do Y
- Additional configuration options
ms.topic: how-to | ||
--- | ||
|
||
## Help option |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it should be more descriptive, perhaps this? Also, H1, not H2.
## Help option | |
# Customize help output |
@@ -5,5 +5,5 @@ ms.date: 05/22/2022 | |||
ms.topic: include |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should move to live with the commandline docs docs/standard/commandline/includes/scl-preview.md
- name: How to | ||
items: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have this opened up by default since it's the only collapsible child
- name: How to | |
items: | |
- name: How to | |
expanded: true | |
items: |
href: ../standard/commandline/tab-completion.md | ||
- name: Customize help | ||
href: ../standard/commandline/help.md | ||
- name: Design guidance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this is down at the bottom, would it make more sense to have it above the how to area?
|
||
1. Create a folder named *scl* for the project, and then open a command prompt in the new folder. | ||
|
||
1. Run the following command: | ||
|
||
```dotnetcli | ||
dotnet new console --framework net6.0 | ||
dotnet new console --framework net9.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the version important? Can we just create a new .NET console app and things will work regardless? The previous release supported standard 2.0, is that still the case with beta 5? Does the code shown in here use some .NET 9-specific feature?
href: ../standard/commandline/use-middleware.md | ||
- name: How to | ||
items: | ||
- name: Parse and invoke the result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, with all of these articles here under a How to section, if they're really how-to articles, it helps SEO if their file name is how-to-*.md
.
High level overview:
Internal previews
Toggle expand/collapse