From ef5de3ed96a69e6dee06421a927392c00e744b46 Mon Sep 17 00:00:00 2001 From: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com> Date: Thu, 31 Mar 2022 13:30:07 +0200 Subject: [PATCH] Move completions to module format (#195) * Move custom completions to module format * Describe usage in README of custom completions --- custom-completions/cargo/README.md | 9 ++++-- custom-completions/cargo/cargo-completions.nu | 2 +- custom-completions/git/README.md | 9 ++++-- custom-completions/make/README.md | 9 ++++-- custom-completions/make/make-completions.nu | 4 +-- custom-completions/npm/README.md | 9 ++++-- custom-completions/winget/README.md | 9 ++++-- .../winget/winget-completions.nu | 32 +++++++++---------- 8 files changed, 54 insertions(+), 29 deletions(-) diff --git a/custom-completions/cargo/README.md b/custom-completions/cargo/README.md index 99e9b3f..50d60cc 100644 --- a/custom-completions/cargo/README.md +++ b/custom-completions/cargo/README.md @@ -1,5 +1,10 @@ # Cargo Custom Completions -### Definition +This script provides custom completions for cargo. +It can be used by importing its exported commands via: -These scripts should be used to demonstrate how create custom completions for cargo. +``` +use path/to/cargo/cargo-completions.nu * +``` + +With `path/to` being either the relative path of the file to your current working directory or its absolute path. diff --git a/custom-completions/cargo/cargo-completions.nu b/custom-completions/cargo/cargo-completions.nu index ba1c075..6ce923b 100644 --- a/custom-completions/cargo/cargo-completions.nu +++ b/custom-completions/cargo/cargo-completions.nu @@ -23,7 +23,7 @@ def "nu-complete cargo features" [] { open Cargo.toml | get features | transpose | get column0 } -extern "cargo run" [ +export extern "cargo run" [ ...args: any # arguments --bin: string@"nu-complete cargo bins" # Name of the bin target to run --example: string@"nu-complete cargo examples" # Name of the example target to run diff --git a/custom-completions/git/README.md b/custom-completions/git/README.md index f8aa344..4ed6f8e 100644 --- a/custom-completions/git/README.md +++ b/custom-completions/git/README.md @@ -1,5 +1,10 @@ # Git Custom Completions -### Definition +This script provides custom completions for git. +It can be used by importing its exported commands via: -These scripts should be used to demonstrate how create custom completions for git. +``` +use path/to/git/git-completions.nu * +``` + +With `path/to` being either the relative path of the file to your current working directory or its absolute path. diff --git a/custom-completions/make/README.md b/custom-completions/make/README.md index aeb34a6..4e08118 100644 --- a/custom-completions/make/README.md +++ b/custom-completions/make/README.md @@ -1,5 +1,10 @@ # Make Custom Completions -### Definition +This script provides custom completions for make. +It can be used by importing its exported commands via: -These scripts should be used to demonstrate how create custom completions for make. +``` +use path/to/make/make-completions.nu * +``` + +With `path/to` being either the relative path of the file to your current working directory or its absolute path. diff --git a/custom-completions/make/make-completions.nu b/custom-completions/make/make-completions.nu index faedadf..0c2eecf 100644 --- a/custom-completions/make/make-completions.nu +++ b/custom-completions/make/make-completions.nu @@ -14,7 +14,7 @@ def "nu-complete make" [] { ls **/*|where type == dir|get name } - extern "make" [ + export extern "make" [ command: string@"nu-complete make" --always-make(-B) # Unconditionally make all targets. --directory(-C): string@"nu-complete make dirs" # Change to DIRECTORY before doing anything. @@ -53,4 +53,4 @@ def "nu-complete make" [] { --new-file: string@"nu-complete files" --assume-new: string@"nu-complete files" --warn-undefined-variables # Warn when an undefined variable is referenced. - ] \ No newline at end of file + ] diff --git a/custom-completions/npm/README.md b/custom-completions/npm/README.md index 3062154..d6c0041 100644 --- a/custom-completions/npm/README.md +++ b/custom-completions/npm/README.md @@ -1,5 +1,10 @@ # NPM Custom Completions -### Definition +This script provides custom completions for npm. +It can be used by importing its exported commands via: -These scripts should be used to demonstrate how create custom completions for npm. +``` +use path/to/npm/npm-completions.nu * +``` + +With `path/to` being either the relative path of the file to your current working directory or its absolute path. diff --git a/custom-completions/winget/README.md b/custom-completions/winget/README.md index c4b1df3..3706f38 100644 --- a/custom-completions/winget/README.md +++ b/custom-completions/winget/README.md @@ -1,5 +1,10 @@ # Winget Custom Completions -### Definition +This script provides custom completions for winget. +It can be used by importing its exported commands via: -These scripts should be used to demonstrate how create custom completions for winget. +``` +use path/to/winget/winget-completions.nu * +``` + +With `path/to` being either the relative path of the file to your current working directory or its absolute path. diff --git a/custom-completions/winget/winget-completions.nu b/custom-completions/winget/winget-completions.nu index ee80383..e5450a0 100644 --- a/custom-completions/winget/winget-completions.nu +++ b/custom-completions/winget/winget-completions.nu @@ -1,14 +1,14 @@ # Written by Genna # Windows Package Manager -extern winget [ +export extern winget [ --version(-v): bool, # Display the version of the tool --info: bool, # Display general info of the tool --help(-?): bool, # Display the help for this command ] # Installs the given package -extern "winget install" [ +export extern "winget install" [ query?: string@"nu-complete winget install name", --query(-q): string@"nu-complete winget install name", # The query used to search for a package --manifest(-m): path, # The path to the manifest of the package @@ -99,12 +99,12 @@ def "winget show" [ } # Manage sources of packages -extern "winget source" [ +export extern "winget source" [ --help(-?): bool # Display the help for this command ] # Add a new source -extern "winget source add" [ +export extern "winget source add" [ --name(-n): string, # Name of the source --arg(-a): string, # Argument given to the source --type(-t): string@"nu-complete winget source type", # Type of the source @@ -142,26 +142,26 @@ def "winget source list" [ } # Update current sources -extern "winget source update" [ +export extern "winget source update" [ --name(-n): string, # Name of the source --help(-?): bool # Display the help for this command ] # Remove current sources -extern "winget source remove" [ +export extern "winget source remove" [ --name(-n): string, # Name of the source --help(-?): bool # Display the help for this command ] # Reset sources -extern "winget source reset" [ +export extern "winget source reset" [ --name(-n): string, # Name of the source --force: bool, # Forces the reset of the sources --help(-?): bool # Display the help for this command ] # Export current sources -extern "winget source export" [ +export extern "winget source export" [ --name(-n): string, # Name of the source --help(-?): bool # Display the help for this command ] @@ -263,7 +263,7 @@ def "winget list" [ } # Upgrades the given package -extern "winget upgrade" [ +export extern "winget upgrade" [ query?: string, --query(-q): string, # The query used to search for a package --manifest(-m): path, # The path to the manifest of the package @@ -287,7 +287,7 @@ extern "winget upgrade" [ ] # Uninstalls the given package -extern "winget uninstall" [ +export extern "winget uninstall" [ query?: string@"nu-complete winget uninstall package name", --query(-q): string@"nu-complete winget uninstall package name", # The query used to search for a package --manifest(-m): path, # The path to the manifest of the package @@ -304,7 +304,7 @@ extern "winget uninstall" [ ] # Helper to hash installer files -extern "winget hash" [ +export extern "winget hash" [ file?: path, # File to be hashed --file(-f): path, # File to be hashed --msix(-m): bool, # Input file will be treated as msix; signature hash will be provided if signed @@ -312,26 +312,26 @@ extern "winget hash" [ ] # Validates a manifest file -extern "winget validate" [ +export extern "winget validate" [ manifest?: path, # The path to the manifest to be validated --manifest: path, # The path to the manifest to be validated --help(-?): bool # Display the help for this command ] # Open settings or set administrator settings -extern "winget settings" [ +export extern "winget settings" [ --enable: string, # Enables the specific administrator setting --disable: string, # Disables the specific administrator setting --help(-?): bool # Display the help for this command ] # Shows the status of experimental features -extern "winget features" [ +export extern "winget features" [ --help(-?): bool # Display the help for this command ] # Exports a list of the installed packages -extern "winget export" [ +export extern "winget export" [ output?: path, # File where the result is to be written --output(-o): path, # File where the result is to be written --source(-s): string@"nu-complete winget install source", # Export packages from the specified source @@ -340,7 +340,7 @@ extern "winget export" [ --help(-?): bool # Display the help for this command ] -extern "winget import" [ +export extern "winget import" [ import-file?: path, # File describing the packages to install --import-file(-i): path, # File describing the packages to install --ignore-unavailable: bool, # Ignore unavailable packages