From 4ee26725ba1800579cd5793684c0b63c3ad8be35 Mon Sep 17 00:00:00 2001 From: nikitar020 Date: Sat, 5 Jan 2019 23:39:48 +0700 Subject: [PATCH] Fix the bug with determining which flags are actually provided in the command line --- config.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/config.go b/config.go index d5e2035..93ebfd6 100644 --- a/config.go +++ b/config.go @@ -9,14 +9,13 @@ import ( "path/filepath" "github.com/liamg/aminal/config" "github.com/liamg/aminal/version" - "strings" ) -func isFlagProvided(flagName string) bool { - result := false +func getActuallyProvidedFlags() map[string]bool { + result := make(map[string]bool) flag.Visit(func(f *flag.Flag) { - result = strings.Compare(f.Name, flagName) == 0 + result[f.Name] = true }) return result @@ -36,6 +35,7 @@ func getConfig() *config.Config { flag.BoolVar(&slomo, "slomo", slomo, "Render in slow motion (useful for debugging)") flag.Parse() // actual parsing and fetching flags from the command line + actuallyProvidedFlags := getActuallyProvidedFlags() if showVersion { v := version.Version @@ -54,15 +54,15 @@ func getConfig() *config.Config { } // Override values in the configuration file with the values specified in the command line, if any. - if isFlagProvided("shell") { + if actuallyProvidedFlags["shell"] { conf.Shell = shell } - if isFlagProvided("debug") { + if actuallyProvidedFlags["debug"] { conf.DebugMode = debugMode } - if isFlagProvided("slomo") { + if actuallyProvidedFlags["slomo"] { conf.Slomo = slomo }