-
Notifications
You must be signed in to change notification settings - Fork 476
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 recipes to generated completion scripts #573
Comments
@casey If the |
@gotcha Good question! I was thinking that I would first write the completion script to a string while generating it in If you can show me what should be added to the completion script (either in a gist, or a PR), then I can make the changes in rust to add it when it's generated too. |
In case of bash, I do this dirty trick to replace source <(OPTS=$(just --list | tail -n +2 | sed 's/ / /g' | tr -d '\n'); just --completions bash | sed "s/ <ARGUMENTS>... /$OPTS/g") Do you think it would make sense to include similar solution in default script generated by |
That's an awesome trick! I'd be worried about adding it into the default script, just because it adds dependencies on |
I agree. |
Ah, okay, I misunderstood. Actually, that's already available if you do |
Great! I confirm, the following does the trick: source <(just --completions bash | sed 's/ <ARGUMENTS>... /$(just --summary)/g') We will appreciate making it default in |
Actually, can you check to see if you're using the latest version of Just? I think recipe completions may have already been added to the latest version of the bash completions script: Line 28 in c647efa
|
You are correct. just of mine wasn't up to date. After upgrading to v0.8.4 I got it working. The only remark I can make is that it works only for the first task that I try to execute. For instance here only just foo bar baz |
Ah, great. I don't use bash myself, so I forgot that it already had completions.
That's definitely an unfortunate limitation of the completion script. I opened #756 to track it. |
This solution does not support aliases which are sometimes made up of several characters
To support aliases and other section we can use this command:
You can also add checking for justfile to expand completions only when file exists:
Is it possible to add autocomplete that would match only sections and aliases from justfile?
In this case I would like to request new command something like --project-only or something like that. And it resolving limitation of the completion script so You can press 2 xTAB, use option, use again 2 x TAB, use next option etc etc. So it helps with auto-completion for:
Like: It also works dynamically for each of project, so You will have other auto-completions for each of justfile (without changing anything). Like: |
I wasn't sure whether completion scripts should complete aliases, as well as full recipe names. My thought was completions scripts should only complete full recipe names, since aliases are often made to be shorter to type, but might clutter completion results. I'm curious how others feel about this though.
Unfortunately this only works if the justfile is in the current directory, but not if it's in a parent directory.
Do you mean auto-complete that only completes recipe names and aliases? Is this because it's simpler, or because it's undesirable to complete flags and options? |
I don't have sharp opinion, but probably yes, I would include aliases too. |
Solution for Bash with parent directories (fixed):
|
In #572, I'll be landing a
--completions
flag to makejust
output completion scripts for various shells. However, these completion scripts should also allow completing recipe names (likebuild
ortest
). I'll need to add this functionality separately.See #223 for completion scripts that others have written.
Add recipe completions to:
The text was updated successfully, but these errors were encountered: