mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
684366e050
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
Former-commit-id: 520945c4cd979999ce7da8cc60544e1e390de3fe [formerly 5c73f94c28f67f0fb25ecff7ce999480ff0d873f] [formerly bdb85560ceeac89408c8588213ef88c5b774c8c7 [formerly fc06f642f2
]]
Former-commit-id: dc0c81b78cdec8656bd25dad84f9589486300d34 [formerly b18cd1e0bced8b34b31863fb7c4e714905bbf0d9]
Former-commit-id: cd84e54f28b9c56c3ced9da79f7fcb9a659f674a
61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
package cmd
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/filebrowser/filebrowser/v2/auth"
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/pflag"
|
|
)
|
|
|
|
func init() {
|
|
configCmd.AddCommand(configSetCmd)
|
|
addConfigFlags(configSetCmd.Flags())
|
|
}
|
|
|
|
var configSetCmd = &cobra.Command{
|
|
Use: "set",
|
|
Short: "Updates the configuration",
|
|
Long: `Updates the configuration. Set the flags for the options
|
|
you want to change.`,
|
|
Args: cobra.NoArgs,
|
|
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
|
|
s, err := d.store.Settings.Get()
|
|
checkErr(err)
|
|
|
|
hasAuth := false
|
|
cmd.Flags().Visit(func(flag *pflag.Flag) {
|
|
switch flag.Name {
|
|
case "signup":
|
|
s.Signup = mustGetBool(cmd, flag.Name)
|
|
case "auth.method":
|
|
hasAuth = true
|
|
case "shell":
|
|
s.Shell = strings.Split(strings.TrimSpace(mustGetString(cmd, flag.Name)), " ")
|
|
case "branding.name":
|
|
s.Branding.Name = mustGetString(cmd, flag.Name)
|
|
case "branding.disableExternal":
|
|
s.Branding.DisableExternal = mustGetBool(cmd, flag.Name)
|
|
case "branding.files":
|
|
s.Branding.Files = mustGetString(cmd, flag.Name)
|
|
}
|
|
})
|
|
|
|
getUserDefaults(cmd, &s.Defaults, false)
|
|
|
|
var auther auth.Auther
|
|
if hasAuth {
|
|
s.AuthMethod, auther = getAuthentication(cmd)
|
|
err = d.store.Auth.Save(auther)
|
|
checkErr(err)
|
|
} else {
|
|
auther, err = d.store.Auth.Get(s.AuthMethod)
|
|
checkErr(err)
|
|
}
|
|
|
|
err = d.store.Settings.Save(s)
|
|
checkErr(err)
|
|
printSettings(s, auther)
|
|
}, pythonConfig{}),
|
|
}
|