From 4511084eb78fa1afb4530b032e0510808fb6dc83 Mon Sep 17 00:00:00 2001 From: 1138-4EB <1138-4EB@users.noreply.github.com> Date: Mon, 7 Jan 2019 23:52:12 +0100 Subject: [PATCH] do not use viper in config subcmds --- cmd/config.go | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index deef481f..58c20fe7 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -13,7 +13,6 @@ import ( "github.com/filebrowser/filebrowser/v2/settings" "github.com/spf13/cobra" "github.com/spf13/pflag" - v "github.com/spf13/viper" ) func init() { @@ -29,26 +28,21 @@ var configCmd = &cobra.Command{ } func addConfigFlags(f *pflag.FlagSet) { - addUserFlags(f) - vaddP(f, "signup", "s", false, "allow users to signup") - vadd(f, "shell", "", "shell command to which other commands should be appended") + f.BoolP("signup", "s", false, "allow users to signup") + f.String("shell", "", "shell command to which other commands should be appended") - vadd(f, "auth.method", string(auth.MethodJSONAuth), "authentication type") - vadd(f, "auth.header", "", "HTTP header for auth.method=proxy") + f.String("auth.method", string(auth.MethodJSONAuth), "authentication type") + f.String("auth.header", "", "HTTP header for auth.method=proxy") - vadd(f, "recaptcha.host", "https://www.google.com", "use another host for ReCAPTCHA. recaptcha.net might be useful in China") - vadd(f, "recaptcha.key", "", "ReCaptcha site key") - vadd(f, "recaptcha.secret", "", "ReCaptcha secret") + f.String("recaptcha.host", "https://www.google.com", "use another host for ReCAPTCHA. recaptcha.net might be useful in China") + f.String("recaptcha.key", "", "ReCaptcha site key") + f.String("recaptcha.secret", "", "ReCaptcha secret") - vadd(f, "branding.name", "", "replace 'File Browser' by this name") - vadd(f, "branding.files", "", "path to directory with images and custom styles") - vadd(f, "branding.disableExternal", false, "disable external links such as GitHub links") - - if err := v.BindPFlags(f); err != nil { - panic(err) - } + f.String("branding.name", "", "replace 'File Browser' by this name") + f.String("branding.files", "", "path to directory with images and custom styles") + f.Bool("branding.disableExternal", false, "disable external links such as GitHub links") } func getAuthentication(cmd *cobra.Command) (settings.AuthMethod, auth.Auther) {