allow "cscli completion..." without configuration file (#1340)
This commit is contained in:
parent
8120fe7d5d
commit
b6aca81ebd
2 changed files with 18 additions and 1 deletions
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -151,7 +152,11 @@ It is meant to allow you to manage bans, parsers/scenarios/etc, api and generall
|
|||
if err := rootCmd.PersistentFlags().MarkHidden("branch"); err != nil {
|
||||
log.Fatalf("failed to make branch hidden : %s", err)
|
||||
}
|
||||
cobra.OnInitialize(initConfig)
|
||||
|
||||
if os.Args[1] != "completion" {
|
||||
cobra.OnInitialize(initConfig)
|
||||
}
|
||||
|
||||
/*don't sort flags so we can enforce order*/
|
||||
rootCmd.Flags().SortFlags = false
|
||||
rootCmd.PersistentFlags().SortFlags = false
|
||||
|
|
|
@ -127,3 +127,15 @@ declare stderr
|
|||
run -0 echo "$stderr"
|
||||
assert_output --partial "Local Api Metrics:"
|
||||
}
|
||||
|
||||
@test "$FILE 'cscli completion' with or without configuration file" {
|
||||
run -0 cscli completion bash
|
||||
assert_output --partial "# bash completion for cscli"
|
||||
run -0 cscli completion zsh
|
||||
assert_output --partial "# zsh completion for cscli"
|
||||
rm "${CONFIG_DIR}/config.yaml"
|
||||
run -0 cscli completion bash
|
||||
assert_output --partial "# bash completion for cscli"
|
||||
run -0 cscli completion zsh
|
||||
assert_output --partial "# zsh completion for cscli"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue