casey / just

🤖 Just a command runner
https://just.systems
Creative Commons Zero v1.0 Universal
18.42k stars 421 forks source link

Modules breaks autocompletion #2191

Open Spatenheinz opened 3 days ago

Spatenheinz commented 3 days ago

I am using Just (v.1.29.1) via nix (from nixos-unstable branch). It looks to me like the auto-completion is not working as intended when i have a mod <module_name> in my Justfile. The two scenarios:

  1. trying to autocomplete with no modules just ...: Gives me the recipes as expected.
  2. trying to do just --unstable ...: Gives me all flags and [ARGUMENTS].... which I am not sure is the intended behavior?

From other issues I do understand that this is a tricky matter, but I think auto-completion is very valuable when working with modules.

casey commented 3 days ago

Hmm, interesting. I'm guessing --unstable breaks the autocomplete script.

Can you try export JUST_UNSTABLE=1 instead of --unstable and see if that works?

Spatenheinz commented 3 days ago

It looks look like export JUST_UNSTABLE=1 does fix the problem. It also looks like even without --unstable completion is broken. I guess this is not intentional?

casey commented 2 days ago

It also looks like even without --unstable completion is broken. I guess this is not intentional?

Can you give an example of what's breaking? For example, a partial command line along with where you hit tab, and what came up and what was expected?

laniakea64 commented 2 days ago

It was not said what shell this is happening with, so not sure if I'm seeing the same issue, but in case it is:

With bash shell, tab-completion does not complete justfile recipes of literally any justfile containing working mod statements. It instead tries to complete filenames.

An alternative to setting JUST_UNSTABLE is to run something like

eval "$(just --completions bash | sed -r -e 's/just --summary/just --unstable --summary/g')"

But neither option is a full workaround. It does fix tab-completing recipes after typing only just, but after typing just --unstable it will only tab-complete command-line options, it no longer completes recipe names at this point. This part is not specific to --unstable, same happens with other command-line options e.g. --dry-run with a justfile that doesn't use any unstable features.

I think what is being requested here is two things: 1) Fix completion of recipe names when a command-line option is specified. 2) Tab-completion to use --unstable when --unstable is given on the command line.

@Spatenheinz Do I understand correctly? Also, what shell are you using?

Spatenheinz commented 2 days ago

I have only tried in bash. @laniakea64 I agree on point 1. I am not sure I understand point 2. The problem i was initially referring to was actually independent of --unstable. I cannot list recipes when modules are included.