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: added clap shell completion and implemented Default trait on Args #17

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

abhi-xyz
Copy link

  • added build.rs: cargo will generate shell completion for bash, zsh, fish, nushell and elvish on source change
  • implemented Default trait on Args: Now we can write tests without all those unnecessary args by replacing them with ..Default::default()

abhi-xyz and others added 3 commits December 26, 2024 15:36
- added build.rs: cargo will generate shell completion for bash, zsh,
fish, nushell and elvish on source change
- implemented Default trait on Args: Now we can write tests without all
those unnecessary args by replacing them with ..Default::default()
@thewh1teagle
Copy link
Owner

I'm wondering if it's possible to install the completions automatically when the program start. I don't see any mention about it in the clap_complete crate

@abhi-xyz
Copy link
Author

abhi-xyz commented Dec 27, 2024

Yep, technically its possible.

As developers, we usually bundle shell completions and man pages with the release assets, and it is the job of the package manager to place them in the appropriate directories. These directories vary across systems and shells. Even if we manage to determine the directories where shells automatically pick up completions, there are additional challenges, such as deciding whether to install them locally (user-specific) or globally (system-wide).

We generally leave these choices to the users or package managers. As far I have seen, it is the package manager that handles tasks like placing man pages and completion files in the correct locations during installation. I wouldn’t recommend trying to install completions manually within the program itself.

However, if you still want to handle it manually, you can include commands like these in an installation script:

mkdir -p ~/.local/share/fish/vendor_completions.d
cp completions/mc.fish ~/.local/share/fish/vendor_completions.d/

Each shell has specific directories where it automatically picks up completions without requiring users to source them explicitly in their configuration files. For example:

Bash: /usr/share/bash-completion/completions/ or ~/.bash_completion.d/

Fish: `~/.local/share/fish/vendor_completions.d

https://fishshell.com/docs/current/completions.html#where-to-put-completions

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