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

zsh autocomplete issue tabbing after passing --set VAR value #695

Closed
kenden opened this issue Oct 9, 2020 · 3 comments · Fixed by #697
Closed

zsh autocomplete issue tabbing after passing --set VAR value #695

kenden opened this issue Oct 9, 2020 · 3 comments · Fixed by #697
Labels

Comments

@kenden
Copy link
Contributor

kenden commented Oct 9, 2020

There is an issue with the
zsh autocompletion when pressing tab after
just --set VAR value
It displays a block of error.

How to reproduce

Load autocompletion in your terminal

$ source <(just --completions=zsh)

Create a justfile

GREET_WORD := 'Hello'
greet name:
  @echo {{GREET_WORD}} {{name}}!

Use it

$ just greet Robert
Hello Robert!

Use it with autocompletion

If we want to set the variable GREET_WORD from the command line using --set, we would enter:
$ just --set GREET_WORD then press Tab
---> It autocompletes to:
$ just --set GREET_WORD greet
here, it should not autocomplete with a target, or anything, just wait for the user to enter a value.

But, if we type a correct content for the variable:
just --set GREET_WORD Hola then press Tab
----> we get:

$ just --set GREET_WORD Hola …error: The argument '--set <VARIABLE> <VALUE>' requires a value but none was supplied

USAGE:
    just --color <COLOR> --set <VARIABLE> <VALUE> --shell <SHELL> --shell-arg <SHELL-ARG>... <--choose|--completions <SHELL>|--dump|--edit|--init|--evaluate|--list|--show <RECIPE>|--summary|--variables>

For more information try --help
error: The argument '--set <VARIABLE> <VALUE>' requires a value but none was supplied

USAGE:
    just --color <COLOR> --set <VARIABLE> <VALUE> --shell <SHELL> --shell-arg <SHELL-ARG>... <--choose|--completions <SHELL>|--dump|--edit|--init|--evaluate|--list|--show <RECIPE>|--summary|--variables>

For more information try --help
error: The argument '--set <VARIABLE> <VALUE>' requires a value but none was supplied

USAGE:
    just --color <COLOR> --set <VARIABLE> <VALUE> --shell <SHELL> --shell-arg <SHELL-ARG>... <--choose|--completions <SHELL>|--dump|--edit|--init|--evaluate|--list|--show <RECIPE>|--summary|--variables>

For more information try --help

-> Here, it should have autocompleted with a target.

You can see the steps above in this recording:
just-autocomplete-zsh-issue

Note

It would be nice to be able to set parameters with --set using space OR =, e.g.
just --set GREET_WORD Hola greet Robert
or
just --set GREET_WORD=Hola greet Robert
or
just --set=GREET_WORD=Hola greet Robert
or (with quotes, even):
just --set="GREET_WORD=Hola" greet Robert
(just mentioning this because using a = sign would not trigger this issue)

Versions

just v0.8.0
zsh 5.7.1 (x86_64-apple-darwin19.0)

@casey casey added the bug label Oct 9, 2020
@casey
Copy link
Owner

casey commented Oct 9, 2020

Thank you for the detailed report!

There's actually an alternative syntax for setting variables:

just GREET_WORD=Hola

If an initial argument is of the form .*=.*, just will interpret it as a set. Is that a viable workaround? This is still definitely a bug.

@heyrict, I was wondering you had an idea for a quick fix for this? If not, no worries!

@kenden
Copy link
Contributor Author

kenden commented Oct 9, 2020

@casey Thanks! I prefer using just --set for setting variables because:

  • on the command line, pressing tab after just --set will autocomplete with variables from the justfile, I don't need to remember them,
  • in a script/CI config, it makes it (IMHO!) clearer that we are setting a variable.
    (except that in just --set GREET_WORD Hola greet Robert, it's hard to see what is a variable, what it a target and what is a target's parameter, another reason why allowing an = with --set would be would be nice to have. Other programs often allow both, ex docker run --env=http_proxy --env https_proxy).

Also, pressing tab after just GREET_WORD=Hola there is also an error:

just GREET_WORD=Hola …Justfile does not contain recipe `GREET_WORD=Hola`.
Justfile does not contain recipe `GREET_WORD=Hola`.
Justfile does not contain recipe `GREET_WORD=Hola`.

---> It should have autocompleted with a target.

@heyrict
Copy link
Contributor

heyrict commented Oct 9, 2020

I'll publish a patch later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants