From cc917a515f6ef24aa886472721988c5ae991feb4 Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Tue, 22 Oct 2019 08:45:37 -0400 Subject: [PATCH] Remove printSetting switch from cmdSet --- cmdSet.go | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/cmdSet.go b/cmdSet.go index 8757102..68a2d39 100644 --- a/cmdSet.go +++ b/cmdSet.go @@ -19,32 +19,34 @@ func init() { RegisterCommand(command) } +func printSetting(cmd []string) { + switch cmd[1] { + case "load": + loadFromToml() + printToView("Feed", fmt.Sprintf("Loading config from toml")) + case "downloadPath": + printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], downloadPath)) + case "outputFormat": + printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], outputFormat)) + case "dateFormat": + printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], dateFormat)) + case "timeFormat": + printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], timeFormat)) + case "cmdPrefix": + printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], cmdPrefix)) + default: + printToView("Feed", fmt.Sprintf("Unknown config value %s", cmd[1])) + } + return +} func cmdSet(cmd []string) { if len(cmd) < 2 { printToView("Feed", "No config value specified") return } if len(cmd) < 3 { - switch cmd[1] { - case "load": - loadFromToml() - printToView("Feed", fmt.Sprintf("Loading config from toml")) - case "downloadPath": - printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], downloadPath)) - case "outputFormat": - printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], outputFormat)) - case "dateFormat": - printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], dateFormat)) - case "timeFormat": - printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], timeFormat)) - case "cmdPrefix": - printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], cmdPrefix)) - default: - printToView("Feed", fmt.Sprintf("Unknown config value %s", cmd[1])) - } - - return + printSetting(cmd) } switch cmd[1] { case "downloadPath":