Skip to content
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

feat: clap_completion #1056

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TwistingTwists
Copy link
Contributor

  • autocompletion for the cli

No issue created yet.

Description

Adding auto completion for the cli - to ease developer UX.


This PR has:

  • been tested to ensure log ingestion and log query works.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added documentation for new or modified features or behaviors.

@TwistingTwists
Copy link
Contributor Author

TwistingTwists commented Dec 26, 2024

Questions about this PR:

  1. it changes the CONFIG struct. Since, CONFIG is used almost everywhere in code, it'll cause lots of small changes across codebase. The changes will look like this

  2. Currently the new enum ParseableCommand delegates the methods related to Config struct in impl ParseableCommand.
    I think this could be handled by defining a trait .

Is there an alternate approach I haven't considered that you would like me to try?

@de-sh
Copy link
Contributor

de-sh commented Jan 20, 2025

@TwistingTwists can you please resolve conflicts and update your branch?

@TwistingTwists
Copy link
Contributor Author

TwistingTwists commented Jan 21, 2025

Yup. will do by EOD

... so that pb completions can add chat completions via clap_complete

- Need to refactor Config struct
@TwistingTwists
Copy link
Contributor Author

Unresolved Questions about this PR:

  1. currently, the cli exits after generations the completions from the pb completions command . Since this is inside Config struct, we don't return anything. This is not ideal.

if there is an alternate you would like me to try, please let me know.
cc @de-sh

- Fish: `pb util completion fish | source`
- Nushell:
```nu
pb util completion nushell | save "completions-pb.nu"
Copy link
Contributor

@de-sh de-sh Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pb is a different cli tool, a client to the parseable(server) actually.

Can we have a argument/flag similar to --help that when set will print the completions for the specific shell. i.e.

parseable --shell-completion-config nushell | save "parseable-completions.nu"

this way we can continue to use the CLI as is, setting the default behavior of the CLI to be "don't output" when the flag is not set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also a good way to do this, rather than adding a command. I'll implement this.


impl ShellCompletion {
pub fn generate(&self, cmd: &mut clap::Command) -> Vec<u8> {
use clap_complete::generate;
Copy link
Contributor

@de-sh de-sh Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clap_complete is missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants