mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
WTF-553 Fix config.yml creation issue on first run
This commit is contained in:
parent
d08a5baf60
commit
a8bde9ecbe
@ -17,6 +17,8 @@ type Flags struct {
|
|||||||
Module string `short:"m" long:"module" optional:"yes" description:"Display info about a specific module, i.e.: 'wtf -m=todo'"`
|
Module string `short:"m" long:"module" optional:"yes" description:"Display info about a specific module, i.e.: 'wtf -m=todo'"`
|
||||||
Profile bool `short:"p" long:"profile" optional:"yes" description:"Profile application memory usage"`
|
Profile bool `short:"p" long:"profile" optional:"yes" description:"Profile application memory usage"`
|
||||||
Version bool `short:"v" long:"version" description:"Show version info"`
|
Version bool `short:"v" long:"version" description:"Show version info"`
|
||||||
|
|
||||||
|
hasCustom bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFlags creates an instance of Flags
|
// NewFlags creates an instance of Flags
|
||||||
@ -48,7 +50,7 @@ func (flags *Flags) RenderIf(version string, config *config.Config) {
|
|||||||
|
|
||||||
// HasCustomConfig returns TRUE if a config path was passed in, FALSE if one was not
|
// HasCustomConfig returns TRUE if a config path was passed in, FALSE if one was not
|
||||||
func (flags *Flags) HasCustomConfig() bool {
|
func (flags *Flags) HasCustomConfig() bool {
|
||||||
return len(flags.Config) > 0
|
return flags.hasCustom
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasModule returns TRUE if a module name was passed in, FALSE if one was not
|
// HasModule returns TRUE if a module name was passed in, FALSE if one was not
|
||||||
@ -70,15 +72,18 @@ func (flags *Flags) Parse() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no config file is explicitly passed in as a param,
|
// If we have a custom config, then we're done parsing parameters, we don't need to
|
||||||
// set the flag to the default config file
|
// generate the default value
|
||||||
if !flags.HasCustomConfig() {
|
flags.hasCustom = (len(flags.Config) > 0)
|
||||||
homeDir, err := utils.Home()
|
if flags.hasCustom == true {
|
||||||
if err != nil {
|
return
|
||||||
fmt.Printf("Error: %v\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
flags.Config = filepath.Join(homeDir, ".config", "wtf", "config.yml")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no config file is explicitly passed in as a param then set the flag to the default config file
|
||||||
|
homeDir, err := utils.Home()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Error: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
flags.Config = filepath.Join(homeDir, ".config", "wtf", "config.yml")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user