feat: add to CLI
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
This commit is contained in:
parent
a91f433788
commit
b568e9d6a6
@ -13,8 +13,6 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(configCmd)
|
rootCmd.AddCommand(configCmd)
|
||||||
}
|
}
|
||||||
@ -34,6 +32,7 @@ func addConfigFlags(cmd *cobra.Command) {
|
|||||||
addUserFlags(cmd)
|
addUserFlags(cmd)
|
||||||
cmd.Flags().StringP("baseURL", "b", "/", "base url of this installation")
|
cmd.Flags().StringP("baseURL", "b", "/", "base url of this installation")
|
||||||
cmd.Flags().BoolP("signup", "s", false, "allow users to signup")
|
cmd.Flags().BoolP("signup", "s", false, "allow users to signup")
|
||||||
|
cmd.Flags().String("shell", "", "shell command to which other commands should be appended")
|
||||||
|
|
||||||
cmd.Flags().String("auth.method", string(auth.MethodJSONAuth), "authentication type")
|
cmd.Flags().String("auth.method", string(auth.MethodJSONAuth), "authentication type")
|
||||||
cmd.Flags().String("auth.header", "", "HTTP header for auth.method=proxy")
|
cmd.Flags().String("auth.header", "", "HTTP header for auth.method=proxy")
|
||||||
@ -94,6 +93,7 @@ func printSettings(s *types.Settings, auther types.Auther) {
|
|||||||
fmt.Fprintf(w, "\nBase URL:\t%s\n", s.BaseURL)
|
fmt.Fprintf(w, "\nBase URL:\t%s\n", s.BaseURL)
|
||||||
fmt.Fprintf(w, "Sign up:\t%t\n", s.Signup)
|
fmt.Fprintf(w, "Sign up:\t%t\n", s.Signup)
|
||||||
fmt.Fprintf(w, "Auth method:\t%s\n", s.AuthMethod)
|
fmt.Fprintf(w, "Auth method:\t%s\n", s.AuthMethod)
|
||||||
|
fmt.Fprintf(w, "Shell:\t%s\t", strings.Join(s.Shell, " "))
|
||||||
fmt.Fprintln(w, "\nBranding:")
|
fmt.Fprintln(w, "\nBranding:")
|
||||||
fmt.Fprintf(w, "\tName:\t%s\n", s.Branding.Name)
|
fmt.Fprintf(w, "\tName:\t%s\n", s.Branding.Name)
|
||||||
fmt.Fprintf(w, "\tFiles override:\t%s\n", s.Branding.Files)
|
fmt.Fprintf(w, "\tFiles override:\t%s\n", s.Branding.Files)
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/asdine/storm"
|
"github.com/asdine/storm"
|
||||||
"github.com/filebrowser/filebrowser/bolt"
|
"github.com/filebrowser/filebrowser/bolt"
|
||||||
@ -40,6 +41,7 @@ override the options.`,
|
|||||||
Key: generateRandomBytes(64), // 256 bits
|
Key: generateRandomBytes(64), // 256 bits
|
||||||
BaseURL: mustGetString(cmd, "baseURL"),
|
BaseURL: mustGetString(cmd, "baseURL"),
|
||||||
Signup: mustGetBool(cmd, "signup"),
|
Signup: mustGetBool(cmd, "signup"),
|
||||||
|
Shell: strings.Split(strings.TrimSpace(mustGetString(cmd, "shell")), " "),
|
||||||
Defaults: defaults,
|
Defaults: defaults,
|
||||||
AuthMethod: authMethod,
|
AuthMethod: authMethod,
|
||||||
Branding: types.Branding{
|
Branding: types.Branding{
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/filebrowser/filebrowser/types"
|
"github.com/filebrowser/filebrowser/types"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
@ -34,6 +36,8 @@ you want to change.`,
|
|||||||
s.Signup = mustGetBool(cmd, "signup")
|
s.Signup = mustGetBool(cmd, "signup")
|
||||||
case "auth.method":
|
case "auth.method":
|
||||||
auth = true
|
auth = true
|
||||||
|
case "shell":
|
||||||
|
s.Shell = strings.Split(strings.TrimSpace(mustGetString(cmd, "shell")), " ")
|
||||||
case "branding.name":
|
case "branding.name":
|
||||||
s.Branding.Name = mustGetString(cmd, "branding.name")
|
s.Branding.Name = mustGetString(cmd, "branding.name")
|
||||||
case "branding.disableExternal":
|
case "branding.disableExternal":
|
||||||
|
|||||||
@ -12,7 +12,7 @@ type Settings struct {
|
|||||||
AuthMethod AuthMethod `json:"authMethod"`
|
AuthMethod AuthMethod `json:"authMethod"`
|
||||||
Branding Branding `json:"branding"`
|
Branding Branding `json:"branding"`
|
||||||
Commands map[string][]string `json:"commands"`
|
Commands map[string][]string `json:"commands"`
|
||||||
Shell []string `json:"shell"` // TODO add to cli
|
Shell []string `json:"shell"`
|
||||||
Rules []Rule `json:"rules"` // TODO: use this add to cli
|
Rules []Rule `json:"rules"` // TODO: use this add to cli
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user