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

shell completion scripts #812

Open
Eloquencere opened this issue Sep 19, 2024 · 5 comments
Open

shell completion scripts #812

Eloquencere opened this issue Sep 19, 2024 · 5 comments

Comments

@Eloquencere
Copy link

Eloquencere commented Sep 19, 2024

Hi, I use croc extensively in my workflow and as a result I have written my own simple zsh completion script, which works well me. Just thought of contributing it here so that, other people using the cli can also benefit from it.

It's just a zsh completion script since zsh has been my primary shell. It would be great if someone can guide me to include it in the file structure, I'm not really proficient in golang, I'm just happy with croc and would like to contribute to the project.

@schollz
Copy link
Owner

schollz commented Sep 19, 2024

happy to have the PR, go ahead and add it anywhere and I can move it to where it needs.

@Eloquencere
Copy link
Author

Sure thing! I'll get it submitted as soon as possible

@MaxenceG2M
Copy link

Hi @Eloquencere, hi @schollz,

On release 9.6.6 (and before that), completion scripts for bash and zsh was included in artefacts.

Release 9.6.7 include a PR to change the image used to build:

Update and fix the docker image deplyment build by @rehanone in #645

Since then, the artefact has changed its name style and no longer contains the completion scripts.

I don't know a lot about Go, but it seems that completion scripts can be generated from the code.
Might be a better solution to keep flexibility?

@Eloquencere
Copy link
Author

Hi @MaxenceG2M,
First of all, before I get started I want to say, that I don't know how @schollz implemented the completion script. Every CLI does it slightly differently. Some of them take up the effort of moving them directly to the root file system while others give you the option to generate it on the spot upon request and expect you to load the file onto a directory under fpath(in zsh at least). Since I use a heavy wrapper around croc to suit my specific needs and until I can figure out how to migrate that functionality to croc proper, I would rather the completion follow the latter than the former, to prevent it from clashing with my wrapper's completion.

Yes, it might seem tempting to stitch the script generation functionality right into the code and there are a few benefits to that like, completion script generation can be shell-independent as the format would remain more or less the same and the completion script can better flow with the actual implementation of the CLI.
The disadvantages, in my opinion, would be, that I severely lack the expertise in bash and fish shells so the code would highly favour the shell I know best(zsh) and even if I didn't lack the expertise, maintenance of the code could become cumbersome since the styles of actually representing every completion sentence is a bit different in every language. I'm not saying it's impossible but, I am saying it would invite more trouble at the moment than just getting things up and running.

@Eloquencere
Copy link
Author

Hey @schollz I just wanted to know if PR #813 is still under consideration. Its been a while and there seems to be no movement from your side or other collaborators.

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

No branches or pull requests

3 participants