Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd dotnet help <verb> support #5922
Conversation
This commit adds supports for getting more detailed help by using the `dotnet help <verb>` syntax (e.g. `dotnet help build`). This change opens up the URL that is specified for each verb in the default browser on the user's machine, so internet access is required.
|
@dotnet-bot test RHEL7.2 x64 Release Build please |
| @@ -169,10 +127,12 @@ internal static int ProcessArgs(string[] args, ITelemetry telemetryClient = null | |||
| telemetryClient.TrackEvent(command, null, null); | |||
|
|
|||
| int exitCode; | |||
| Func<string[], int> builtIn; | |||
| if (s_builtIns.TryGetValue(command, out builtIn)) | |||
| // Func<string[], int> builtIn; | |||
eerhardt
Mar 6, 2017
Member
Can be removed
Can be removed
blackdwarf
Mar 6, 2017
Author
Fixed.
Fixed.
| { | ||
| public static Dictionary<string, BuiltInCommandMetadata> Commands = new Dictionary<string, BuiltInCommandMetadata> | ||
| { | ||
| ["add"] = new BuiltInCommandMetadata |
eerhardt
Mar 6, 2017
Member
Does this handle sub commands? Ex. 'dotnet help add package'
Does this handle sub commands? Ex. 'dotnet help add package'
jonsequitur
Mar 6, 2017
Collaborator
We should probably add this as a feature into the new parser. @blackdwarf, it'll give you a chance to kick the tires there.
We should probably add this as a feature into the new parser. @blackdwarf, it'll give you a chance to kick the tires there.
jonsequitur
Mar 6, 2017
Collaborator
The new parser may make this a bit more natural. We could just add DocLink as a property on Command. The advantage there will be that the structure of the commands and options is compiler-enforced and tab completion will light up for free for the help-able commands.
The new parser may make this a bit more natural. We could just add DocLink as a property on Command. The advantage there will be that the structure of the commands and options is compiler-enforced and tab completion will light up for free for the help-able commands.
blackdwarf
Mar 11, 2017
Author
@jonsequitur this sounds like a good idea, but see below on the need to possibly keep this information in a separate file. Not saying that this would be impossible in the new parser, of course. :)
@jonsequitur this sounds like a good idea, but see below on the need to possibly keep this information in a separate file. Not saying that this would be impossible in the new parser, of course. :)
|
I'm a big fan of this user experience. It is very similar to "git help pull". I'm wondering if the aka.ms links are a good choice. There are a problems with them that I see:
I'd rather see these in a simple text format (in a separate file) and encourage the dotnet/docs repo folks to be partly responsible for the experience. That's really tough with opaque links. /cc @mairaw @BillWagner |
|
@richlander the aka.ms links are a so-so choice in my view. You are right that they are opaque and the final URL is not visible unless they are resolved. However, given the moves that will happen with the docs in the next week, this was the only sane way of testing the feature and making sure it is at least somewhat future proof. There are several options on changing this:
Regardless, the approach taken here can support all three above. |
|
I wouldn't block your PR on this issue. I'd suggest taking the PR and opening an issue on this topic. I think the cost of opening a file to read contents should be pretty minimal. It should be what 50ms (on a 5400 RPM disk) to do that work? |
Agreed. Especially since:
|
|
We discussed a few trade-offs concerning a link versus more thorough on-disk help. The main advantages to the links were that the documentation can be updated more easily and the up-front download of the CLI will be smaller. |
|
I've been thinking about this for a while yesterday and I've come to the conclusion that the aka.ms links are not bad. We would want to establish a model where we can have as stable URLs as possible so that any changes to the docs URLs do not necessitate re-shipping of the CLI. aka.ms is just one means to the end with that regard. Changing them I haven't found to be that hard, honestly. As for the separate file, I plan on making that change to this PR, but with the above I am afraid that I don't see a pressing need. Any change to the CLI, including a simple text file that contains the mappings of commands to their URLs, would have to go through the same PR process as a code change, that is to say, moving the mapping elsewhere does not impact docs' team potential ownership of these links. |
|
Ah, that's a good point. Here's a middle ground ... in the code, you could add a comment that includes the target of the aka.ms link. That would satisfy my concern. |
|
@richlander sure, that makes sense. Will do. |
|
Cool. Can you remove "/en-us" from the links? I always remove that. Once we have loc'd docs, then the non-locale specific links make the right choice whereas the locale ones are specific. English FTW, right? Thanks. |
|
Done. |
|
LGTM |
|
@livarcocc you ok with this change? |
| @@ -65,5 +66,39 @@ public void WhenHelpOptionIsPassedToDotnetItPrintsUsage(string helpArg) | |||
| cmd.Should().Pass(); | |||
| cmd.StdOut.Should().ContainVisuallySameFragment(HelpText); | |||
| } | |||
|
|
|||
| [Fact] | |||
| public void WhenInvalidCommandIsPassedToDOtnetHelpItPrintsError() | |||
livarcocc
Mar 15, 2017
NIT: Typo here at ToDOtnet
NIT: Typo here at ToDOtnet
| .ExecuteWithCapturedOutput("help invalid"); | ||
|
|
||
| cmd.Should().Fail(); | ||
| cmd.StdErr.Should().ContainVisuallySameFragment($"Specified command invalid is not a valid CLI command. Please specify a valid CLI commands. For more information, run dotnet help."); |
livarcocc
Mar 15, 2017
Should the command name be in single quotes: Specified command 'invalid' is ...?
Should the command name be in single quotes: Specified command 'invalid' is ...?
livarcocc
Mar 15, 2017
Also, "...please specify a valid CLI commands" seems wrong.
Should we just go ahead and print the commands here?
Also, "...please specify a valid CLI commands" seems wrong.
Should we just go ahead and print the commands here?
blackdwarf
Mar 15, 2017
•
Author
We could, but I wold like to keep the error as well, mostly because it will tell users what happened.
We could, but I wold like to keep the error as well, mostly because it will tell users what happened.
| Cli.BuiltInCommandMetadata builtIn; | ||
| if (Cli.BuiltInCommandsCatalog.Commands.TryGetValue(commandNameArgument.Value, out builtIn)) | ||
| { | ||
| // var p = Process.Start(GetProcessStartInfo(builtIn)); |
livarcocc
Mar 15, 2017
Remove this comment.
Remove this comment.
blackdwarf
Mar 15, 2017
Author
Fixed.
Fixed.
|
|
||
| app.OnExecute(() => | ||
| { | ||
| Cli.BuiltInCommandMetadata builtIn; |
livarcocc
Mar 15, 2017
Does the type here really need the namespace?
Does the type here really need the namespace?
blackdwarf
Mar 15, 2017
Author
Fixed.
Fixed.
| if (Cli.BuiltInCommandsCatalog.Commands.TryGetValue(commandNameArgument.Value, out builtIn)) | ||
| { | ||
| // var p = Process.Start(GetProcessStartInfo(builtIn)); | ||
| var process = ConfigureProcess(builtIn.DocLink.ToString()); |
livarcocc
Mar 15, 2017
Should we make the DocLink a string straight up instead of doing this conversion?
Should we make the DocLink a string straight up instead of doing this conversion?
blackdwarf
Mar 15, 2017
Author
Sure.
Sure.
| @@ -8,6 +8,7 @@ | |||
| using Microsoft.DotNet.Tools.Test.Utilities; | |||
livarcocc
Mar 15, 2017
Do we need to test the mapping between commands and URLs?
Do we need to test the mapping between commands and URLs?
blackdwarf
Mar 15, 2017
Author
It doesn't have to be a fixed thing. We could, I guess, but they can change.
It doesn't have to be a fixed thing. We could, I guess, but they can change.
|
@livarcocc do say if you're ok with the change to get merged now. |
|
Woohoo! Thanks @blackdwarf! |
This commit adds supports for getting more detailed help by using the
dotnet help <verb>syntax (e.g.dotnet help build). This change opens up the URL that is specified for each verb in the default browser on the user's machine, so internet access is required.The PR removes the
s_builtInsfromdotnet/Program.csinto a separate class and adds a class that contains the links. I went this way to minimize code changes overall as well as to create a situation where we have a single place to add a command to the built-ins dictionary so that things do not go out of sync. Another approach is that this could be a property on theCommandLineApplicationclass that each command can fill in./cc @richlander