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

Add --completion option #657

Merged
merged 7 commits into from
May 6, 2022
Merged

Add --completion option #657

merged 7 commits into from
May 6, 2022

Conversation

spenserblack
Copy link
Collaborator

This allows the user to generate completions by passing --completion <SHELL>. This PR also

  • Moves the CLI App creation to a separate build_cli function. This was necessary as the
    clap_generate docs seem to imply that a separate instance of the CLI app struct is necessary
    for generating completions. For the purposes of the App struct's lifetime, a few borrowed
    iterators had to be changed to be taken by the app struct.

Can be used for generating completions.
Generates completions for the specified shell. This commit also

- Creates a separate `build_cli` fn. Necessary as CLI has to be rebuilt
  for completion generation.
- Changes a few iter borrows to take the values. Necessary for CLI App
  struct's lifetime.
@spenserblack
Copy link
Collaborator Author

Note that the "real" diff is actually much smaller than the git diff. A simple change in indentation results in a massive number of lines changed 🤣

src/cli.rs Outdated Show resolved Hide resolved
src/cli.rs Outdated Show resolved Hide resolved
src/cli.rs Outdated Show resolved Hide resolved
Copy link
Owner

@o2sh o2sh left a comment

Choose a reason for hiding this comment

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

That's a neat feature. I wasn't aware of shell completion.

Left a few minor comments.

src/cli.rs Show resolved Hide resolved
@o2sh o2sh self-requested a review May 6, 2022 18:52
#657 (comment)
Co-authored-by: Ossama Hjaji <ossama-hjaji@live.fr>
spenserblack and others added 4 commits May 6, 2022 14:56
Co-authored-by: Ossama Hjaji <ossama-hjaji@live.fr>
#657 (comment)
Co-authored-by: Ossama Hjaji <ossama-hjaji@live.fr>
#657 (comment)
Co-authored-by: Ossama Hjaji <ossama-hjaji@live.fr>
@o2sh o2sh merged commit 9aec77c into o2sh:main May 6, 2022
@spenserblack spenserblack deleted the feature/completions branch May 6, 2022 19:23
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.

None yet

2 participants