You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How were you invoking prior to using new CommandLineBuilder(rootCommand).UseDefaults()? I'm guessing you were directly instantiating a Parser, which won't include default middleware. (The Command.Invoke/Command.InvokeAsync extension methods also call UseDefaults internally so you could potentially use those if you want something a little more succinct.)
Docs are in the works (dotnet/docs#28072) but ideally this distinction would be more obvious just from the API shape. Any suggestions on how we could have made this clearer at the API level? Would an explicit remark in the XML documentation have helped?
It sounds like if step 1 had worked, you wouldn't have had to dig into 2 and 3, which are implementation details that people should not have to care about, but the API didn't "just work" the way it needs to, and also there's this order of operations bug that might have bitten you as well.
I was using Command.Invoke, but it wasn't working. I didn't know it called UseDefaults.
When I checked sentinel directory it had 2 other entries. Probably other Debug sessions.
There was no $HOME/.dotnet-suggest-registration.txt file.
I think these details should be in some doc about how to develop and test a cli tool that uses these APIs.
On this topic, I'm currently using command.Invoke to invoke my root command, but I'm trying to now switch to using a commandlinebuilder to add middleware, and can't figure out how to actually run the application?
I've created a parser with commandLineBuilder.Build(), but running Parse doesn't do anything?
Parse returns a ParseResult. You can call ParseResult.Invoke or ParseResult.InvokeAsync to trigger a call to the appropriate handler based on the parsed input.
Those are implementation details that might change as we fix some of the bugs in this area. Would you have needed to look at these details had completions just worked?
@jonsequitur sorry, it took me a while to see this notification.
No, it would not have mattered, but if those bugs are still there these procedures should be on the docs until those bugs are fixed, right?
Possibly. It's not the kind of thing we typically document in the official docs, especially given the tools is in preview and significant changes are planned in this area. I tend to think the time is better spent just fixing the bug. Even if we document the process, most people aren't going to take the time to investigate it. I really appreciate that you did. Most people aren't going to be so patient.
Activity
jonsequitur commentedon Feb 19, 2022
How were you invoking prior to using
new CommandLineBuilder(rootCommand).UseDefaults()? I'm guessing you were directly instantiating aParser, which won't include default middleware. (TheCommand.Invoke/Command.InvokeAsyncextension methods also callUseDefaultsinternally so you could potentially use those if you want something a little more succinct.)Docs are in the works (dotnet/docs#28072) but ideally this distinction would be more obvious just from the API shape. Any suggestions on how we could have made this clearer at the API level? Would an explicit remark in the XML documentation have helped?
It sounds like if step 1 had worked, you wouldn't have had to dig into 2 and 3, which are implementation details that people should not have to care about, but the API didn't "just work" the way it needs to, and also there's this order of operations bug that might have bitten you as well.
giggio commentedon Feb 19, 2022
I was using Command.Invoke, but it wasn't working. I didn't know it called UseDefaults.
When I checked sentinel directory it had 2 other entries. Probably other Debug sessions.
There was no $HOME/.dotnet-suggest-registration.txt file.
I think these details should be in some doc about how to develop and test a cli tool that uses these APIs.
brickscrap commentedon Feb 25, 2022
On this topic, I'm currently using command.Invoke to invoke my root command, but I'm trying to now switch to using a commandlinebuilder to add middleware, and can't figure out how to actually run the application?
I've created a parser with commandLineBuilder.Build(), but running Parse doesn't do anything?
jonsequitur commentedon Feb 25, 2022
Parsereturns aParseResult. You can callParseResult.InvokeorParseResult.InvokeAsyncto trigger a call to the appropriate handler based on the parsed input.brickscrap commentedon Feb 25, 2022
Ah, I didn't have
using System.CommandLine.Parsing. Strange that VS didn't recommend it, thank youjonsequitur commentedon Feb 25, 2022
I wonder if it should be considered a bug that
ParseResultis in this namespace. 🤔brickscrap commentedon Feb 25, 2022
Well, as I've said before I'm a bit of an amateur, but it certainly wasn't obvious to me
jonsequitur commentedon Feb 25, 2022
We want it to be obvious.
jonsequitur commentedon Mar 10, 2022
Docs have been published. Have a look:
https://docs.microsoft.com/en-us/dotnet/standard/commandline/tab-completion
giggio commentedon Jul 4, 2022
@jonsequitur I just came back to check on the docs, they are good, but they still don't go into the details I mentioned in numbers 2, and 3:
$TEMP/system-commandline-sentinel-files/directory.$HOME/.dotnet-suggest-registration.txtfile that kept the apps that were registered.It is an improvement, for sure, but these details mattered to me when I was developing.
jonsequitur commentedon Jul 11, 2022
Those are implementation details that might change as we fix some of the bugs in this area. Would you have needed to look at these details had completions just worked?
giggio commentedon Sep 5, 2022
@jonsequitur sorry, it took me a while to see this notification.
No, it would not have mattered, but if those bugs are still there these procedures should be on the docs until those bugs are fixed, right?
jonsequitur commentedon Sep 7, 2022
Possibly. It's not the kind of thing we typically document in the official docs, especially given the tools is in preview and significant changes are planned in this area. I tend to think the time is better spent just fixing the bug. Even if we document the process, most people aren't going to take the time to investigate it. I really appreciate that you did. Most people aren't going to be so patient.