From cd92a0f40583fb6e7ae99ae41a5fe79adbc08c6a Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Fri, 8 Dec 2023 15:28:42 -0300 Subject: [PATCH] Add rustup completions (#690) I did some more work and deleted the old auto-generated `rustup` --- .../auto-generate/completions/rustup.nu | 4 -- custom-completions/rustup/rustup.nu | 63 +++++++++++++++++-- 2 files changed, 59 insertions(+), 8 deletions(-) delete mode 100644 custom-completions/auto-generate/completions/rustup.nu diff --git a/custom-completions/auto-generate/completions/rustup.nu b/custom-completions/auto-generate/completions/rustup.nu deleted file mode 100644 index 02a64f49..00000000 --- a/custom-completions/auto-generate/completions/rustup.nu +++ /dev/null @@ -1,4 +0,0 @@ -extern "rustup" [ - - ...args -] \ No newline at end of file diff --git a/custom-completions/rustup/rustup.nu b/custom-completions/rustup/rustup.nu index 429a6a36..58b9b61c 100644 --- a/custom-completions/rustup/rustup.nu +++ b/custom-completions/rustup/rustup.nu @@ -22,7 +22,9 @@ def "nu-complete rustup toolchain" [] { def "nu-complete rustup toolchain list" [] { ^rustup toolchain list | lines - # TODO: add `stable` `nightly` and any other starndard toolchain + | append 'stable' + | append 'beta' + | append 'nightly' } def "nu-complete rustup target" [] { @@ -101,6 +103,31 @@ def "nu-complete rustup self" [] { | parse -r '\s*(?P[^ ]+) \s*(?P\w.*)' } +def "nu-complete rustup set" [] { + ^rustup set + | str replace --regex --multiline '(rustup[\s\S]*(?=SUBCOMMANDS:))' '' + | str replace --regex --multiline '\n+DISCUSSION[\s\S]*' '' + | lines + | where $it starts-with " " + | parse -r '\s*(?P[^ ]+) \s*(?P\w.*)' +} + +def "nu-complete rustup set profile" [] { + ['minimal', 'default', 'complete'] +} + +def "nu-complete rustup set auto-self-update" [] { + ['enable', 'disable', 'check-only'] +} + +def "nu-complete rustup completions" [] { + ['bash', 'elvish', 'fish', 'powershell', 'zsh', 'cargo', 'rustup'] +} + +def "nu-complete rustup completions shell" [] { + ['bash', 'elvish', 'fish', 'powershell', 'zsh'] +} + # ------------------ export extern commands ------------------ export extern "rustup" [ @@ -128,6 +155,12 @@ export extern "rustup toolchain" [ --help(-h) # Print help information ] +export extern "rustup toolchain install" [ + command?: string@"nu-complete rustup toolchain list" + --help(-h) # Print help information +] + + export extern "rustup toolchain uninstall" [ command?: string@"nu-complete rustup toolchain list" ] @@ -193,9 +226,31 @@ export extern "rustup self" [ ] export extern "rustup set" [ - # TODO + command?: string@"nu-complete rustup set" + --help(-h) # Print help information +] + +export extern "rustup set profile" [ + command?: string@"nu-complete rustup set profile" + --help(-h) # Print help information +] + +export extern "rustup set auto-self-update" [ + command?: string@"nu-complete rustup set auto-self-update" + --help(-h) # Print help information ] export extern "rustup completions" [ - # TODO -] \ No newline at end of file + command?: string@"nu-complete rustup completions" + --help(-h) # Print help information +] + +export extern "rustup completions rustup" [ + command?: string@"nu-complete rustup completions shell" + --help(-h) # Print help information +] + +export extern "rustup completions cargo" [ + command?: string@"nu-complete rustup completions shell" + --help(-h) # Print help information +]