Skip to content

Commit

Permalink
Adjust the config set command for excludes
Browse files Browse the repository at this point in the history
  • Loading branch information
penguwin authored and muesli committed Sep 2, 2020
1 parent 72299c1 commit c64c04b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions cmd/knoxite/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var (
if len(args) < 2 {
return fmt.Errorf("set needs to know which value to set")
}
return executeConfigSet(args[0], args[1])
return executeConfigSet(args[0], args[1:])
},
}
configInfoCmd = &cobra.Command{
Expand Down Expand Up @@ -116,7 +116,7 @@ func executeConfigAlias(alias string) error {
return cfg.Save()
}

func executeConfigSet(option string, value string) error {
func executeConfigSet(option string, values []string) error {
// This probably wont scale for more complex configuration options but works
// fine for now.
parts := strings.Split(option, ".")
Expand All @@ -133,17 +133,21 @@ func executeConfigSet(option string, value string) error {
opt := strings.ToLower(parts[1])
switch opt {
case "url":
repo.Url = value
repo.Url = values[0]
case "compression":
repo.Compression = value
repo.Compression = values[0]
case "encryption":
repo.Encryption = value
repo.Encryption = values[0]
case "tolerance":
tol, err := strconv.Atoi(value)
tol, err := strconv.Atoi(values[0])
if err != nil {
return fmt.Errorf("Failed to convert %s to uint for the fault tolerance option: %v", opt, err)
}
repo.Tolerance = uint(tol)
case "store_excludes":
repo.StoreExcludes = values
case "restore_excludes":
repo.RestoreExcludes = values
default:
return fmt.Errorf("Unknown configuration option: %s", opt)
}
Expand Down

0 comments on commit c64c04b

Please sign in to comment.