mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
a7e867a699
This commit replaces github.com/spf13/viper with github.com/knadh/koanf. Koanf is very similar library to viper, with less dependencies and several quality of life differences. This also allows most config options to be defined by ENV. Lastly it also enables the use of split configuration files which can be configured by setting the --config flag multiple times. Co-authored-by: Amir Zarrinkafsh <nightah@me.com>
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func newCompletionCmd() (cmd *cobra.Command) {
|
|
cmd = &cobra.Command{
|
|
Use: "completion [bash|zsh|fish|powershell]",
|
|
Short: "Generate completion script",
|
|
Long: completionLong,
|
|
Args: cobra.ExactValidArgs(1),
|
|
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
|
|
DisableFlagsInUseLine: true,
|
|
Run: cmdCompletionRun,
|
|
}
|
|
|
|
return cmd
|
|
}
|
|
|
|
func cmdCompletionRun(cmd *cobra.Command, args []string) {
|
|
var err error
|
|
|
|
switch args[0] {
|
|
case "bash":
|
|
err = cmd.Root().GenBashCompletion(os.Stdout)
|
|
case "zsh":
|
|
err = cmd.Root().GenZshCompletion(os.Stdout)
|
|
case "fish":
|
|
err = cmd.Root().GenFishCompletion(os.Stdout, true)
|
|
case "powershell":
|
|
err = cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
|
|
default:
|
|
fmt.Printf("Invalid shell provided for completion command: %s\n", args[0])
|
|
os.Exit(1)
|
|
}
|
|
|
|
if err != nil {
|
|
fmt.Printf("Error generating completion: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|