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

completions and modules don't work together #1807

Closed
crdx opened this issue Dec 31, 2023 · 7 comments · Fixed by #1809
Closed

completions and modules don't work together #1807

crdx opened this issue Dec 31, 2023 · 7 comments · Fixed by #1809

Comments

@crdx
Copy link
Contributor

crdx commented Dec 31, 2023

The completions script uses just --summary to fetch a list of recipes. A recipe bar inside module foo is listed as foo::bar, however module recipes can't be invoked like this ("Justfile does not contain recipe foo::bar").

I'm not sure the best solution although I do personally find foo::bar easier syntax to read as foo bar in my mind looks like a recipe foo that takes a parameter bar.

I wonder whether foo::bar should be added as additional valid syntax to run a module's recipe?

@casey
Copy link
Owner

casey commented Dec 31, 2023

Yah, this is definitely annoying.

I would have actually liked to have different recipes be tab separated in the output of just --summary, so that recipes in modules could be space separated, i.e., if there's a recipe foo and a recipe bar in module baz, just --summary would output foo\tbar\sbaz, so then you could split on tabs to the valid recipes. Unfortunately, this would break any scripts which relied on splitting the output of just --summary on spaces, or on whitespace, so I opted to use the :: syntax instead. Eventually, when recipes can have dependencies that are in other modules, I'll probably wind up using the same syntax for dependencies:

mod baz

foo: baz::bar

I'm not opposed to adding foo::bar as an additional syntax to call recipes in modules from the command line. It seems a bit inelegant to add it just to make the lives of completion scripts easier, but I think some people will prefer that syntax anyhow, and if it becomes the actual syntax for dependencies in other modules, being able to use that syntax on the command line makes sense.

@casey
Copy link
Owner

casey commented Dec 31, 2023

Another thing that the completion scripts could do is split on ::, but I have basically never touched the completion scripts personally, and always left them to other brave souls, so I don't know how annoying this would be to do.

@crdx
Copy link
Contributor Author

crdx commented Dec 31, 2023

Differentiating between spaces and tabs in completion results sounds messy to me, and like you said, probably backwards-incompatible.

Developers tend to be used to the concept of namespace separators, and :: is a common one.

In the past I've wanted to use : to create categories of recipe, e.g. make:migration but couldn't because : is not valid in a recipe name. I would use this feature to put all the make recipes in make.just and reference them as a module, which would tidy things up.

Unfortunately if invoking module recipes by :: became the only way, the output of just --list would probably need to change from the neat tabbed output to a flat list with module recipes listed as foo::bar, otherwise it wouldn't be clear how to invoke them.

Not sure what's best either way, so just sharing my thoughts.

@crdx
Copy link
Contributor Author

crdx commented Dec 31, 2023

Unfortunately, this would break any scripts which relied on splitting the output of just --summary on spaces

Not sure if that'd be something worth doing as (at least with bash) it's not the completion script's job to split up the input:

https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html#index-COMP_005fWORDS

It does mention COMP_WORDBREAKS but imo completions are fragile enough even without trying to change the defaults.

@casey
Copy link
Owner

casey commented Dec 31, 2023

Unfortunately if invoking module recipes by :: became the only way, the output of just --list would probably need to change from the neat tabbed output to a flat list with module recipes listed as foo::bar, otherwise it wouldn't be clear how to invoke them.

I'd definitely allow both :: separated and space separated from the command line, since I personally like space-separated, and space is one character, whereas :: is two characters, and requires shift.

Not sure if that'd be something worth doing as (at least with bash) it's not the completion script's job to split up the input:

Ahh, good catch. So I guess separating by tabs wouldn't work anyway.

@casey
Copy link
Owner

casey commented Dec 31, 2023

Fixed in #1809, recipes can now be invoked on the command line with path syntax, i.e., foo::bar.

@crdx
Copy link
Contributor Author

crdx commented Jan 1, 2024

Nice. Thanks.

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 a pull request may close this issue.

2 participants