mirror of https://github.com/spf13/cobra.git
fixing formatting
This commit is contained in:
parent
8b4aa590bb
commit
7006719603
|
@ -40,7 +40,7 @@ let cobra_completer = {|spans|
|
||||||
] {
|
] {
|
||||||
# This will catch the stderr message related to the directive and any other errors,
|
# This will catch the stderr message related to the directive and any other errors,
|
||||||
# such as the command not being a cobra based command
|
# such as the command not being a cobra based command
|
||||||
let result = do --ignore-errors { cobra_active_help=0 run-external $cmd "__complete" ...$spans | complete }
|
let result = do --ignore-errors { COBRA_ACTIVE_HELP=0 run-external $cmd "__complete" ...$spans | complete }
|
||||||
|
|
||||||
if $result != null and $result.exit_code == 0 {
|
if $result != null and $result.exit_code == 0 {
|
||||||
let completions = $result.stdout | lines
|
let completions = $result.stdout | lines
|
||||||
|
|
|
@ -95,3 +95,15 @@ func TestFailGenNushellCompletionFile(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNushellCompletionNoActiveHelp(t *testing.T) {
|
||||||
|
c := &Command{Use: "c", Run: emptyRun}
|
||||||
|
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
assertNoErr(t, c.GenNushellCompletion(buf, true))
|
||||||
|
output := buf.String()
|
||||||
|
|
||||||
|
// check that active help is being disabled
|
||||||
|
activeHelpVar := activeHelpGlobalEnvVar
|
||||||
|
check(t, output, fmt.Sprintf("%s=0", activeHelpVar))
|
||||||
|
}
|
||||||
|
|
|
@ -73,21 +73,17 @@ PowerShell:
|
||||||
Nushell:
|
Nushell:
|
||||||
|
|
||||||
# To configure the Nushell cobra external completer for the first time:
|
# 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 shell or for this setup to take effect.
|
|
||||||
|
|
||||||
# If you have already setup the cobra external completer:
|
|
||||||
# 1. Edit the nushell config file:
|
# 1. Edit the nushell config file:
|
||||||
> config nu
|
> config nu
|
||||||
# 2. Modify the cobra_apps varible to contain this application:
|
# 2. Copy the completer to at the end of the file.
|
||||||
> let cobra_apps = [ "othercobraapp", "%[1]s" ]
|
# 3. Add a section like the following below the cobra_completer:
|
||||||
# 3. You will need to start a new shell for this setup to take effect.
|
$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 external completer can be found [Multiple completer](https://www.nushell.sh/cookbook/external_completers.html#multiple-completer) of the Nushell cookbook.
|
||||||
|
|
||||||
`,cmd.Root().Name()),
|
`,cmd.Root().Name()),
|
||||||
DisableFlagsInUseLine: true,
|
DisableFlagsInUseLine: true,
|
||||||
|
|
Loading…
Reference in New Issue