casey / just

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

Shell completion add nushell support #974

Closed hustcer closed 5 months ago

hustcer commented 3 years ago

Hi, Thanks for the great work, and just currently has no completion support for the modern, powerful and elegant NuShell, is there any plan for this? Thx

nu --version
───┬────────────────────┬────────────────────────────────────────────────────────────────────────────────────
 # │      Column0       │                                      Column1
───┼────────────────────┼────────────────────────────────────────────────────────────────────────────────────
 0 │ version            │ 0.37.0
 1 │ build_os           │ macos-x86_64
 2 │ rust_version       │ rustc 1.55.0
 3 │ cargo_version      │ cargo 1.55.0
 4 │ pkg_version        │ 0.37.0
 5 │ build_time         │ 2021-09-14 19:45:30 +00:00
 6 │ build_rust_channel │ release
 7 │ features           │ clipboard-cli, ctrlc, dataframe, default, rustyline, term, trash, uuid, which, zip
 8 │ installed_plugins  │
───┴────────────────────┴────────────────────────────────────────────────────────────────────────────────────
casey commented 3 years ago

You are most welcome!

Shell completions are currently mostly generated by clap, the argument parsing library. So support for nushell would have to be added to clap, or someone would have to contribute hand-written completion scripts.

hustcer commented 3 years ago

https://github.com/clap-rs/clap/issues/2778

hustcer commented 2 years ago

https://github.com/clap-rs/clap/issues/2778#issuecomment-992733874 Will this help? Thanks

casey commented 2 years ago

Yup, if clap automatically generated nushell completions, that would definitely help.

hustcer commented 2 years ago

Yup, if clap automatically generated nushell completions, that would definitely help.

I mean the last comment they replied: "If nushell works like bash where you have to write your own parser, #3166 could be a big help towards this." It doesn't look like they are going to provide “automatically generated nushell completions” support in clap

casey commented 2 years ago

I think that might make it easier on the clap side to implement nushell completion support, but we would still have to wait for it to be implemented there before Just could take advantage of it.

starthal commented 1 year ago

It looks like Clap has adopted this: https://github.com/clap-rs/clap/tree/master/clap_complete_nushell

Then I imagine this depends on clap v4: https://github.com/casey/just/issues/1084

FrancescElies commented 6 months ago

In the meanwhile you can put the following somewhere in your nushell config

def "nu-complete just" [] {
    (^just --dump --unstable --dump-format json | from json).recipes | transpose recipe data | flatten | where {|row| $row.private == false } | select recipe doc parameters | rename value description
}

# Just: A Command Runner
export extern "just" [
    ...recipe: string@"nu-complete just", # Recipe(s) to run, may be with argument(s)
]

This was stolen from nushell-scripts (now in the link there is a more elaborated version, but I didn't test that yet)

casey commented 5 months ago

Clap v4 support was finally merged, so this will make it into the next release!