-
-
Notifications
You must be signed in to change notification settings - Fork 52
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 completer for tox 4 #2415
Add completer for tox 4 #2415
Conversation
Add completions for https://tox.wiki/ WIP, there are many completions to add. Also need to consider how to support tox3 vs tox4.
Hi @rsteube , I'm interested in adding support for tox and happy to work on it. I've done some digging into the codebase and started a very basic PoC here. Would you be interested in this feature? I may need some guidance during the process, as this would be the first time working with the project or these Go libraries. |
Probably best to use the parser here to create the initial command structure: https://github.com/carapace-sh/carapace-bin/tree/master/cmd/carapace-parse I need to update the docs for it but see the first minute for how it works: https://asciinema.org/a/466859 Store the help output (if available) or https://tox.wiki/en/latest/cli_interface.html of a command (root or subcommand) in a text file. Prepare it a bit for parsing (something like this): It can handle some variants, but it's just a simple regex. cat root.txt | carapace-parse -n tox -s "tox root command" > root.go
cat sub.txt | carapace-parse -n sub -p root -s "subcommand of root" > sub.go
cat susbsub2.txt | carapace-parse -n sub2 -p sub -s "subcommand of sub" > sub_sub2.go |
- pipe all the 'tox subcommand --help' outputs to carapace-parse - some minor manual editing
Thanks for your tip about carapace-parse! 😄 That's jumpstarted it. I also applied your suggestions. Still a work in progress though. |
@rsteube the completer should be complete now, and ready for review. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- common.go
Files in cmd
generally represent a (sub)command.
Moved functions to root.go for consistency since they are small enough.
In another case I've put these in a common
subfolder (alternative).
- snake_case
Go uses camelCase.
- verbose/quiet
Cobra has Count
for this kind of flags.
- Common Flags
Seems these are used in every command.
Cobra has PersistentFlags
which passes them on to subcommands.
It also hides them for subcommands when they are already set on the parent.
- Files / Folder
File completion is explicit in Carapace and needs to be set.
So there is no fallback as shells normally do.
The venv folder name is arbitrary, but it can be an absolute path so folder completion is still beneficial.
- discover, f, m
This is a weird (bad) pattern in some python commands where flags can consume multiple arguments.
I've got basic support for it with Nargs
.
- StyleF(style.ForKeyword)
No need for this, but highlights positive/negative/arbitrary keywords (like true/false) in colors.
- PreInvoke
This changes the workdir for all actions based on the workdir
flag value.
(Assuming this is what the flag is meant for)
Made some minor changes. Just open an issue/pr if I botched something. Thanks! |
Thanks for your feedback and the merge! 😁 |
Add completions for https://tox.wiki/ (based on tox 4.13)