Skip to content

Commit f2556ca

Browse files
authored
Docs improvements (#979)
* docs updates * add linux-x64 rid to dotnet-suggest
1 parent 4c1f1df commit f2556ca

25 files changed

+374
-214
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Next, install the `dotnet try` global tool:
6565
Finally, launch the `dotnet try` pointing to the tutorial directory inside the cloned repository:
6666

6767
```console
68-
> dotnet try <PATH_TO_COMMAND_LINE_API_REPO>/samples/tutorial
68+
> dotnet try <PATH_TO_COMMAND_LINE_API_REPO>/docs
6969
```
7070

7171
## Code of Conduct

docs/DragonFruit-overview.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Options:
7676

7777
## Arguments
7878

79-
In addition to [options](Syntax-Concepts-and-Parser#Options) as shown in the examples above, DragonFruit also supports [arguments](Syntax-Concepts-and-Parser#Arguments). By convention, if you name a parameter in the `Main` method `args`, `argument`, or `arguments`, it will be exposed as an argument rather than an option.
79+
In addition to [options](Syntax-Concepts-and-Parser#Options) as shown in the examples above, DragonFruit also supports [arguments](Syntax-Concepts-and-Parser#Arguments). By convention, if you name a parameter in the `Main` method `args`, `argument`, or `arguments`, it will be exposed as an argument rather than an option.
8080

8181
```csharp
8282
static void Main(int intOption = 42, string[] args = null)
@@ -106,3 +106,4 @@ Options:
106106
The argument follows the same conventions for arity as described in [arguments](Syntax-Concepts-and-Parser.md#Arguments-and-arity).
107107

108108
You can try out DragonFruit by installing the latest preview [package](https://www.nuget.org/packages/System.CommandLine.DragonFruit).
109+

docs/Features-overview.md

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
`System.CommandLine` provides a set of default features for both people using it to develop apps and for the users of those apps. This is a quick overview of some of those features.
1+
`System.CommandLine` provides a set of default features for both people using it to develop apps and for the users of those apps. This is a quick overview of some of those features.
22

33
# Suggestions
44

5-
Programs written using `System.CommandLine` have built-in support for tab completion.
5+
Programs written using `System.CommandLine` have built-in support for tab completion.
66

77
![t-rex-suggestions](https://user-images.githubusercontent.com/547415/50387753-ef4c1280-06b8-11e9-90c8-89466d0bb406.gif)
88

9-
To enable it, the end user has to take a few steps once per shell, outlined [here](dotnet-suggest). Once this is done, completions will work for all apps written using `System.CommandLine`.
9+
To enable it, the end user has to take a few steps once per shell, outlined [here](dotnet-suggest.md). Once this is done, completions will work for all apps written using `System.CommandLine`.
1010

1111
# Help
1212

@@ -38,7 +38,7 @@ Users might be accustomed to different prefixes in different ecosystems, especia
3838

3939
Providing a way to check the version of your app is helpful to your users.
4040

41-
`System.CommandLine` provides this by default. In the [help](Features-overview#Help) example you might have noticed an option, `--version`, that was not explicitly configured in the sample code. When you run your program with this option, you'll see something like this:
41+
`System.CommandLine` provides this by default. In the [help](Features-overview.md#Help) example you might have noticed an option, `--version`, that was not explicitly configured in the sample code. When you run your program with this option, you'll see something like this:
4242

4343
```console
4444
> myapp --version
@@ -56,7 +56,7 @@ Both users and developers often find it useful to see how an app will interpret
5656

5757
The `[parse]` directive tells the parser to parse the input and return a diagram of the result. Some things worth noting in the above example:
5858

59-
* Commands (`myapp`), their child options, and the arguments to those options are grouped using square brackets.
59+
* Commands (`myapp`), their child options, and the arguments to those options are grouped using square brackets.
6060
* For the option result `![ --int-option <not-an-int> ]`, the `!` indicates a parsing error. `not-an-int` could not be parsed to the expected type.
6161
* For the option result `*[ --bool-option <False> ]`, the `*` indicates that a value was not specified on the command line, so the parser's configured default was used. `False` is the effective value for this option.
6262

@@ -83,17 +83,17 @@ One or more response files can be specified in this way. Arguments and options a
8383

8484
# Adaptive rendering
8585

86-
ANSI terminals support a variety of features by including ANSI escape sequences in standard input and output. These sequences can control the cursor, set text attributes and colors, and more. Windows [recently joined](https://blogs.msdn.microsoft.com/commandline/2018/06/27/windows-command-line-the-evolution-of-the-windows-command-line/) Linux and Mac in supporting these features. This is a capability of the new Windows Terminal and can be enabled programmatically in the Windows 10 Console.
86+
Many terminals support a variety of features by including [virtual terminal (VT) escape sequences](https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences) in standard input and output. These sequences can control the cursor, set text attributes and colors, and more. Windows [recently joined](https://blogs.msdn.microsoft.com/commandline/2018/06/27/windows-command-line-the-evolution-of-the-windows-command-line/) Linux and Mac in supporting these features. This is a capability of the new Windows Terminal and can also be enabled programmatically in the Windows 10 Console.
8787

8888
`System.Console.Rendering` adds support for detecting terminal settings and enabling the Window 10 Console's ANSI mode on demand. It also provides an API that can write output that looks correct based on those settings as well as when output is redirected, as is commonly the case on a build server or when your command line app is called by another command line app.
8989

9090
The following are examples of output rendered by the same view code in these three different contexts.
9191

92-
In PowerShell on Windows with ANSI mode enabled:
92+
In PowerShell on Windows with VT mode enabled:
9393

9494
![ansi](https://user-images.githubusercontent.com/547415/50388667-575b2280-06d2-11e9-91ae-36e8ffabbf8a.png)
9595

96-
In PowerShell with ANSI mode disabled:
96+
In PowerShell with VT mode disabled:
9797

9898
![non-ansi](https://user-images.githubusercontent.com/547415/50388673-85d8fd80-06d2-11e9-844b-4690e4b4ab5a.png)
9999

@@ -121,13 +121,13 @@ The raw text written to standard out in the first example is this:
121121

122122
```
123123

124-
In ANSI mode, the Windows Console interprets these escape sequences into cursor movements and colors. As you can see in the first example above, ANSI mode enables the display of RGB colors and underlining that are not supported otherwise on Windows. Most Linux and macOS terminals as well as the Windows Terminal support this form of rendering by default.
125-
126-
The examples above build the table structure by positioning the cursor for each cell and then writing the content. In an ANSI-capable terminal, this is done using ANSI escape sequences such as `\u001b[1;1H`. The equivalent `System.Console` call, which is needed in non-ANSI terminals, looks like this: `Console.SetCursorPosition(0, 0)`. Meanwhile, the third example renders the layout using spaces and newlines, since there is no cursor when output is redirected.
124+
In VT mode, the Windows Console interprets these escape sequences into cursor movements and colors. As you can see in the first example above, VT mode enables the display of RGB colors and underlining that are not supported otherwise on Windows. Most Linux and macOS terminals as well as the Windows Terminal support this form of rendering by default.
127125

128-
Providing a common API across these very different modes so that you don't have to write the code three times is a major goal of `System.CommandLine.Rendering`. The API is still very rough but you can explore these capabilities in the `RenderingPlayground` [sample](https://github.com/dotnet/command-line-api/tree/master/samples/RenderingPlayground).
126+
The examples above build the table structure by positioning the cursor for each cell and then writing the content. In a VT-capable terminal, this is done using ANSI escape sequences such as `\u001b[1;1H`. The equivalent `System.Console` call, which is needed in terminals that don't render VT codes, looks like this: `Console.SetCursorPosition(0, 0)`. Meanwhile, the third example renders the layout using spaces and newlines, since there is no cursor when output is redirected.
129127

130-
## Rendering directives
128+
Providing a common API across these very different modes so that you don't have to write the code three times is a major goal of `System.CommandLine.Rendering`. The API is still very rough but you can explore these capabilities in the `RenderingPlayground` [sample](https://github.com/dotnet/command-line-api/tree/master/samples/RenderingPlayground).
129+
130+
## Rendering directives
131131

132132
Output modes can also be specified directly. If you know that you want a specific form of output, you can bypass the mode detection of `System.CommandLine.Rendering` and use a [directive](Syntax-Concepts-and-Parser.md#directives).
133133

@@ -144,3 +144,4 @@ The supported output modes are:
144144
* `Ansi`: Output is rendered using ANSI escape sequences. In-place re-rendering is supported.
145145
* `NonAnsi`: Output is rendered using `System.Console` cursor positioning. In-place re-rendering is supported.
146146
* `PlainText`: Output is rendered with additional whitespace so that, for example, if redirected to a text file, the layout will look correct. In-place re-rendering is not supported.
147+

docs/Functional-goals.md

+37-29
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Functional goals
22

3-
The high level goals for `System.CommandLine` support our idea that creating great command line experiences for your users can be easy. We have not yet met all of these goals.
3+
The high level goals for `System.CommandLine` support our idea that creating great command line experiences for your users can be easy. We have not yet met all of these goals.
44

55
## Goals for the end user's experience
66

@@ -11,42 +11,50 @@ The high level goals for `System.CommandLine` support our idea that creating gre
1111
## Goals for the programmer's experience
1212

1313
* Help
14-
* Creating some version of help should be automated, requiring no work.
15-
* Help should be informative if descriptions are supplied.
16-
* Help localization should be straightforward.
14+
15+
* Creating some version of help should be automated, requiring no work.
16+
* Help should be informative if descriptions are supplied.
17+
* Help localization should be straightforward.
1718

1819
* Tab suggestion
19-
* It should just work with no effort on the programmer's part.
20-
* It should provide support for enums.
21-
* It should have a mechanism for dynamic values.
22-
* It should stay out of the way of shell suggestions for files and folders.
23-
* Dynamic suggestions should be extensible for other things I might do.
20+
21+
* It should just work with no effort on the programmer's part.
22+
* It should provide support for enums.
23+
* It should have a mechanism for dynamic values.
24+
* It should stay out of the way of shell suggestions for files and folders.
25+
* Dynamic suggestions should be extensible for other things I might do.
2426

2527
* Validation
26-
* If there are parse errors, it should fail before my application code is called.
27-
* It should check the number and type of arguments.
28-
* It should generally fail if there are unmatched tokens, but I should be able to allow it to pass through.
29-
* It should provide default responses for the user on validation issues.
30-
* I should be able to customize the validation messages.
31-
28+
29+
* If there are parse errors, it should fail before my application code is called.
30+
* It should check the number and type of arguments.
31+
* It should generally fail if there are unmatched tokens, but I should be able to allow it to pass through.
32+
* It should provide default responses for the user on validation issues.
33+
* I should be able to customize the validation messages.
34+
3235
* Debugging and testing
33-
* I should not have to turn a string into an array to interact programmatically.
34-
* I should be able to get a visualization of how a string is parsed.
35-
* It should be easy to test parsing in isolation from the application.
36-
* It should be easy to test the application in isolation from parsing.
37-
* I should be able to specify at the command line that I want to attach a debugger.
36+
37+
* I should not have to turn a string into an array to interact programmatically.
38+
* I should be able to get a visualization of how a string is parsed.
39+
* It should be easy to test parsing in isolation from the application.
40+
* It should be easy to test the application in isolation from parsing.
41+
* I should be able to specify at the command line that I want to attach a debugger.
3842

3943
* Acting on parser results
40-
* Argument results should be strongly typed.
41-
* For advanced scenarios, I can alter and re-parse input.
42-
* It should be simple for me to manage exceptions, output, and exit codes.
44+
45+
* Argument results should be strongly typed.
46+
* For advanced scenarios, I can alter and re-parse input.
47+
* It should be simple for me to manage exceptions, output, and exit codes.
4348

4449
* Rendering
45-
* Provide ways to reason about layout rather than just text.
46-
* Hide Windows/Linux/Mac differences for me.
47-
* Take advantage of new Windows 10 console capabilities.
48-
* Hide non-ANSI/ANSI differences for me.
49-
* Make output look correct when redirected to a file.
50+
51+
* Provide ways to reason about layout rather than just text.
52+
* Hide Windows/Linux/Mac differences for me.
53+
* Take advantage of new Windows 10 console capabilities.
54+
* Hide non-ANSI/ANSI differences for me.
55+
* Make output look correct when redirected to a file.
5056

5157
* Extensibility
52-
* I can compose cross-cutting behaviors using packages.
58+
59+
* I can compose cross-cutting behaviors using packages.
60+

docs/History.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# History
22

3-
The new `System.CommandLine`'s lineage can be traced through the experiences of various teams at Microsoft building .NET command line applications. Some of its ideas have been expressed in the `dotnet` CLI and `CommandLineUtils` originally created in ASP.NET with a [popular fork](https://github.com/natemcmaster/CommandLineUtils) by @natemcmaster.
3+
The new `System.CommandLine`'s lineage can be traced through the experiences of various teams at Microsoft building .NET command line applications. Some of its ideas have been expressed in the `dotnet` CLI and `CommandLineUtils` originally created in ASP.NET with a [popular fork](https://github.com/natemcmaster/CommandLineUtils) by @natemcmaster.
44

55
This project is called the "new" `System.CommandLine` because Microsoft also had a `System.CommandLine` project in CoreFxLab that has been retired because it did not meet the current needs.
66

@@ -10,16 +10,17 @@ The addition of global tools to the `dotnet` ecosystem meant the creation of mor
1010

1111
Parsing is a deceptively complex problem. With folks on the team that have been involved in writing complex and successful CLIs, we can work in the other direction, focusing first on a solid core and then working outward toward the functionality and API surface. We're building the foundation that the folks who wrote and worked on the `dotnet` CLI wish they had been able to use. We ran this part of the project in private to ensure the core was solid, and as an all-volunteer effort this phase took painfully long.
1212

13-
The next layer, the API over the core functionality, has undergone a rewrite, and we are fairly happy with how you explicitly define your CLI. Explicitly defining a syntax feels like too much work for many scenarios and we've put a lot of thought and discussion into the idea of "app models" that infer the structure of your CLI from something that is natural to write.
13+
The next layer, the API over the core functionality, has undergone a rewrite, and we are fairly happy with how you explicitly define your CLI. Explicitly defining a syntax feels like too much work for many scenarios and we've put a lot of thought and discussion into the idea of "app models" that infer the structure of your CLI from something that is natural to write.
1414

15-
App models have two aspects: defining the CLI's structure and bridging between parse results and your application.
15+
App models have two aspects: defining the CLI's structure and bridging between parse results and your application.
1616

1717
As an example, one approach is to bind to a method, which is executed with parameters matching the options and arguments your user provided. This method binding works well when mapped one-to-one between the command and the invoked method. You can find this as the basis for the experimental "DragonFruit" model. DragonFruit takes this idea one step furher by wrapping your `Program.Main` entry point and just letting your `Main` method have normal parameters that just happen to be able to be of types other than `string`. We have not yet found a way we like to do subcommands with the DragonFruit model.
1818

1919
Other approaches to binding include binding to classes. A fundamental aspect of `System.CommandLine` is top-level support for app models and binders. These may reside outside `System.CommandLine` and we hope it will be a framework that people with other ideas can build on. The goal is that app models will interoperate with one another allowing many choices for programmers.
2020

2121
## Rendering
2222

23-
We've also done preliminary work on rendering. This is another area where `System.Console` is showing its age. In particular, `System.Console` does not supporting ANSI terminals easily. While `ncurses` has long addressed differing terminal capabilities in the non-Windows world, .NET programmers could benefit from something that works consistently on Windows, Linux, and Mac.
23+
We've also done preliminary work on rendering. This is another area where `System.Console` is showing its age. In particular, `System.Console` does not supporting ANSI terminals easily. While `ncurses` has long addressed differing terminal capabilities in the non-Windows world, .NET programmers could benefit from something that works consistently on Windows, Linux, and Mac.
2424

2525
And with the new Windows Terminal and Windows 10 bringing [virtual terminal capabilities](https://blogs.msdn.microsoft.com/commandline/2018/06/27/windows-command-line-the-evolution-of-the-windows-command-line/) to the Windows console, we think there's an opportunity for .NET APIs that these benefits to users.
26+

0 commit comments

Comments
 (0)