Skip to content

uutils: implement shell completions#2414

Merged
sylvestre merged 8 commits intouutils:masterfrom
miDeb:completions2
Jun 26, 2021
Merged

uutils: implement shell completions#2414
sylvestre merged 8 commits intouutils:masterfrom
miDeb:completions2

Conversation

@miDeb
Copy link
Contributor

@miDeb miDeb commented Jun 15, 2021

This adds a hidden completion subcommand to coreutils. When invoked with
coreutils completion <utility> <shell> a completion file will be printed
to stdout. When running make install those files will be created for all
utilities and copied to the appropriate locations.
make install will install completions for zsh, fish and bash; however,
clap also supports generating completions for powershell and elvish.

With this patch all utilities are required to have a publich uu_app function
that returns a clap::App in addition to the uumain function.

@miDeb miDeb mentioned this pull request Jun 15, 2021
Copy link
Collaborator

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! Nice solution for hashsum too! I just wondered whether usage and after_help should be in uu_app too. I also have some minor suggestions for some utils, which we can make issues for if you don't want to fix them here,

@tertsdiepraam
Copy link
Collaborator

Sorry, I introduced some conflicts this by first merging #2361, could you take a look at those? After that, we should merge this quickly, because it looks good and it will keep conflicting with other PR's.

@sylvestre
Copy link
Contributor

Impressive work. It would be great to have a section in the README to document the user feature :)
thanks

@miDeb miDeb force-pushed the completions2 branch 2 times, most recently from 0c67de2 to ba336b5 Compare June 19, 2021 18:22
@miDeb
Copy link
Contributor Author

miDeb commented Jun 24, 2021

I'll fix the merge conflicts myself, if you don't mind :)

@sylvestre
Copy link
Contributor

@miDeb oh, yes, please, I made a mistake :(
sorry

miDeb added 8 commits June 25, 2021 21:23
This adds a hidden `completion` subcommand to coreutils. When invoked with
`coreutils completion <utility> <shell>` a completion file will be printed
to stdout. When running `make install` those files will be created for all
utilities and copied to the appropriate locations.
`make install` will install completions for zsh, fish and bash; however,
clap also supports generating completions for powershell and elvish.

With this patch all utilities are required to have a publich uu_app function
that returns a clap::App in addition to the uumain function.
@sylvestre sylvestre merged commit 5fce7ec into uutils:master Jun 26, 2021
@sylvestre
Copy link
Contributor

No big deal but maybe handle the error a bit better:

$ cargo run completion ls zs
    Finished dev [unoptimized + debuginfo] target(s) in 0.19s
     Running `target/debug/coreutils completion ls zs`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "[valid values: bash, fish, zsh, powershell, elvish]"', src/bin/coreutils.rs:148:24
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@sylvestre
Copy link
Contributor

or

$ cargo run completion ls
    Finished dev [unoptimized + debuginfo] target(s) in 0.19s
     Running `target/debug/coreutils completion ls`
thread 'main' panicked at 'expected shell as the second parameter', src/bin/coreutils.rs:134:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@tertsdiepraam tertsdiepraam mentioned this pull request Jul 4, 2021
11 tasks
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 this pull request may close these issues.

3 participants