Skip to content

Improve docs for completions #1648

Closed
Closed

Description

@giggio

It's been difficult to find information regarding how to enable completions with this project. I finally got it to work while developing an app.

I didn't know:

  1. I had to use the command line builder (new CommandLineBuilder(rootCommand).UseDefaults()).
  2. I had to pay attention to the $TEMP/system-commandline-sentinel-files/ directory.
  3. There was a $HOME/.dotnet-suggest-registration.txt file that kept the apps that were registered.

I had to dig through several issues, read the source, etc. I almost gave up.

The debugging detailed at this comment helped: #1085 (comment)

We need better docs.

Neither https://github.com/dotnet/command-line-api/blob/main/docs/Features-overview.md#suggestions nor https://github.com/dotnet/command-line-api/blob/main/docs/dotnet-suggest.md go into these details.

Activity

  1. jonsequitur commented on Feb 19, 2022

    @jonsequitur
    Contributor

    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.

  2. giggio commented on Feb 19, 2022

    @giggio
    Author

    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.

  3. brickscrap commented on Feb 25, 2022

    @brickscrap

    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?

  4. jonsequitur commented on Feb 25, 2022

    @jonsequitur
    Contributor

    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.

    image

  5. brickscrap commented on Feb 25, 2022

    @brickscrap

    Ah, I didn't have using System.CommandLine.Parsing. Strange that VS didn't recommend it, thank you

  6. jonsequitur commented on Feb 25, 2022

    @jonsequitur
    Contributor

    I wonder if it should be considered a bug that ParseResult is in this namespace. 🤔

  7. brickscrap commented on Feb 25, 2022

    @brickscrap

    Well, as I've said before I'm a bit of an amateur, but it certainly wasn't obvious to me

  8. jonsequitur commented on Feb 25, 2022

    @jonsequitur
    Contributor

    We want it to be obvious.

  9. giggio commented on Jul 4, 2022

    @giggio
    Author

    @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:

    1. I had to pay attention to the $TEMP/system-commandline-sentinel-files/ directory.
    2. There was a $HOME/.dotnet-suggest-registration.txt file that kept the apps that were registered.

    It is an improvement, for sure, but these details mattered to me when I was developing.

  10. jonsequitur commented on Jul 11, 2022

    @jonsequitur
    Contributor

    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?

  11. giggio commented on Sep 5, 2022

    @giggio
    Author

    @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?

  12. jonsequitur commented on Sep 7, 2022

    @jonsequitur
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions