From ddb39920b4f1fbd51ba6fa0da663391cb8dbe438 Mon Sep 17 00:00:00 2001 From: Jack Wright Date: Sun, 1 Dec 2024 18:44:56 -0800 Subject: [PATCH] More documentation work for nushell --- completions.go | 25 +++++++++---------- nushell_completions.md | 4 --- site/content/completions/_index.md | 4 ++- .../completions/nushell_completions.md | 3 +++ 4 files changed, 18 insertions(+), 18 deletions(-) delete mode 100644 nushell_completions.md create mode 100644 site/content/completions/nushell_completions.md diff --git a/completions.go b/completions.go index f6924ba..a3d16bc 100644 --- a/completions.go +++ b/completions.go @@ -848,21 +848,20 @@ to your powershell profile. Long: fmt.Sprintf(`Generate the autocompletion script for nushell. To configure the Nushell cobra external completer for the first time: - # 1. Copy the output of the command below: - > %[1]s completion nushell - # 2. Edit the nushell config file: - > config nu - # 3. Paste above the "let-env config" line. - # 4. Change the config block's external_completer line to be external_completer: $cobra_completer - # 5. You will need to start a new shel for this setup to take effect. - -If you have already setup the cobra external completer for other Cobra-based applications: # 1. Edit the nushell config file: > config nu - # 2. Modify the cobra_apps variable to contain this new application: - > let cobra_apps = [ "othercobraapp", "%[1]s" ] - # 3. You will need to start a new shell for this setup to take effect. -`, c.Root().Name()), + # 2. Copy the completer to at the end of the file. + # 3. Add a section like the following below at the end of the file: + $env.config.completions.external = { + enable: true + max_results: 100 + completer: $cobra_completer + } + +NOTE: This completer will work for all cobra based commands. +More information can be found in the External Completions (https://www.nushell.sh/book/custom_completions.html#custom-descriptions) section of the Nushell book. +Information on setting up more than one external completer can be found in the Multiple completer (https://www.nushell.sh/cookbook/external_completers.html#multiple-completer) section of the Nushell cookbook. +`), Args: NoArgs, ValidArgsFunction: NoFileCompletions, RunE: func(cmd *Command, args []string) error { diff --git a/nushell_completions.md b/nushell_completions.md deleted file mode 100644 index e0e94eb..0000000 --- a/nushell_completions.md +++ /dev/null @@ -1,4 +0,0 @@ -## Generating Nushell Completions For Your cobra.Command - -Please refer to [Shell Completions](shell_completions.md) for details. - diff --git a/site/content/completions/_index.md b/site/content/completions/_index.md index 5573fd8..8ab4ca0 100644 --- a/site/content/completions/_index.md +++ b/site/content/completions/_index.md @@ -83,7 +83,9 @@ Nushell: completer: $cobra_completer } -NOTE: This completer will work for all cobra based commands. More information can be found in the External Completions (https://www.nushell.sh/book/custom_completions.html#custom-descriptions) section of the Nushell book. Information on setting up more than one external completer can be found in the Multiple completer (https://www.nushell.sh/cookbook/external_completers.html#multiple-completer) section of the Nushell cookbook. +NOTE: This completer will work for all cobra based commands. +More information can be found in the External Completions (https://www.nushell.sh/book/custom_completions.html#custom-descriptions) section of the Nushell book. +Information on setting up more than one external completer can be found in the Multiple completer (https://www.nushell.sh/cookbook/external_completers.html#multiple-completer) section of the Nushell cookbook. `,cmd.Root().Name()), DisableFlagsInUseLine: true, diff --git a/site/content/completions/nushell_completions.md b/site/content/completions/nushell_completions.md new file mode 100644 index 0000000..3bd8065 --- /dev/null +++ b/site/content/completions/nushell_completions.md @@ -0,0 +1,3 @@ +## Generating Nushell Completions For Your cobra.Command + +Please refer to [Shell Completions](_index.md#nushell-completions) for details.