Skip to content

moss::cli: Add dynamic shell completions - #815

Open
otherJL0 wants to merge 7 commits into
aerynOS:mainfrom
otherJL0:dynamic-shell-completions
Open

moss::cli: Add dynamic shell completions#815
otherJL0 wants to merge 7 commits into
aerynOS:mainfrom
otherJL0:dynamic-shell-completions

Conversation

@otherJL0

Copy link
Copy Markdown
Contributor

This PR uses the unstable dynamic completion feature of clap_complete to provide completion candidates at runtime for certain moss commands. This PR adds package names as completion candidates to the subcommands moss install and moss remove and introduces some simple benchmarks with criterion. I'll keep this as a draft for now until the rustqlite migration is complete.

@otherJL0
otherJL0 force-pushed the dynamic-shell-completions branch 3 times, most recently from d35b040 to 5595903 Compare August 14, 2026 01:41
@otherJL0
otherJL0 marked this pull request as ready for review August 14, 2026 01:43
@otherJL0

Copy link
Copy Markdown
Contributor Author

@ermo I've been fiddling with this PR after migration to rustqlite and I think it's ready for review. This one is a little more involved and requires some changes to the moss stone.yaml file for the completions. I'll attach the commands below for each shell to use to export the runtime completions for local testing too. This is my first time working with criterion and the database code for moss so let me know if I'm committing any anti-patterns.

Right now the dynamic completion is enabled for moss install and moss remove only.

echo 'source <(COMPLETE=bash moss)' >> ~/.bashrc
echo 'source <(COMPLETE=zsh moss)'  >> ~/.zshrc 
echo 'COMPLETE=fish moss | source'  > ~/.config/fish/completions/moss.fish

@otherJL0 otherJL0 changed the title moss::cli: Add dynamic shell completions (WIP) moss::cli: Add dynamic shell completions Aug 14, 2026
@otherJL0
otherJL0 force-pushed the dynamic-shell-completions branch 4 times, most recently from 698b032 to 6040173 Compare August 14, 2026 12:48
@otherJL0
otherJL0 force-pushed the dynamic-shell-completions branch from 6040173 to 403bf18 Compare August 21, 2026 22:37
@otherJL0

Copy link
Copy Markdown
Contributor Author

Made some improvements to the completion output. When testing on my machine, I discovered that fish shell has implemented their own moss completion script with dynamic completion populated using native fish functions by filtering through moss list commands: https://github.com/fish-shell/fish-shell/blob/master/share/completions/moss.fish
If the clap dynamic completions are merged and exported, I think the clap completions will take precedence over the embedded fish moss completions but I just wanted to highlight this conflict because it made it a little difficult to test on fish shell on my local machine.

The fish completions provided both package name and package summary as part of their completions which inspired me to borrow their approach:

Screenshot_20260821_185804

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.

1 participant