mirror of https://github.com/liamg/aminal.git
Fix the bug with determining which flags are actually provided in the command line
This commit is contained in:
parent
417c436fe7
commit
4ee26725ba
14
config.go
14
config.go
|
@ -9,14 +9,13 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"github.com/liamg/aminal/config"
|
"github.com/liamg/aminal/config"
|
||||||
"github.com/liamg/aminal/version"
|
"github.com/liamg/aminal/version"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func isFlagProvided(flagName string) bool {
|
func getActuallyProvidedFlags() map[string]bool {
|
||||||
result := false
|
result := make(map[string]bool)
|
||||||
|
|
||||||
flag.Visit(func(f *flag.Flag) {
|
flag.Visit(func(f *flag.Flag) {
|
||||||
result = strings.Compare(f.Name, flagName) == 0
|
result[f.Name] = true
|
||||||
})
|
})
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -36,6 +35,7 @@ func getConfig() *config.Config {
|
||||||
flag.BoolVar(&slomo, "slomo", slomo, "Render in slow motion (useful for debugging)")
|
flag.BoolVar(&slomo, "slomo", slomo, "Render in slow motion (useful for debugging)")
|
||||||
|
|
||||||
flag.Parse() // actual parsing and fetching flags from the command line
|
flag.Parse() // actual parsing and fetching flags from the command line
|
||||||
|
actuallyProvidedFlags := getActuallyProvidedFlags()
|
||||||
|
|
||||||
if showVersion {
|
if showVersion {
|
||||||
v := version.Version
|
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.
|
// 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
|
conf.Shell = shell
|
||||||
}
|
}
|
||||||
|
|
||||||
if isFlagProvided("debug") {
|
if actuallyProvidedFlags["debug"] {
|
||||||
conf.DebugMode = debugMode
|
conf.DebugMode = debugMode
|
||||||
}
|
}
|
||||||
|
|
||||||
if isFlagProvided("slomo") {
|
if actuallyProvidedFlags["slomo"] {
|
||||||
conf.Slomo = slomo
|
conf.Slomo = slomo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue