mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Move responsibility for version display out of flags
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
type Flags struct {
|
||||
Config string `short:"c" long:"config" optional:"yes" description:"Path to config file"`
|
||||
Module string `short:"m" long:"module" optional:"yes" description:"Display info about a specific module, i.e.: 'wtf -m=todo'"`
|
||||
Version bool `short:"v" long:"version" description:"Show Version Info"`
|
||||
Version bool `short:"v" long:"version" description:"Show version info"`
|
||||
}
|
||||
|
||||
func NewFlags() *Flags {
|
||||
@@ -30,6 +30,10 @@ func (flags *Flags) HasModule() bool {
|
||||
return len(flags.Module) > 0
|
||||
}
|
||||
|
||||
func (flags *Flags) HasVersion() bool {
|
||||
return flags.Version == true
|
||||
}
|
||||
|
||||
func (flags *Flags) Parse(version string) {
|
||||
parser := goFlags.NewParser(flags, goFlags.Default)
|
||||
if _, err := parser.Parse(); err != nil {
|
||||
@@ -41,14 +45,10 @@ func (flags *Flags) Parse(version string) {
|
||||
if !flags.HasConfig() {
|
||||
homeDir, err := wtf.Home()
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
flags.Config = filepath.Join(homeDir, ".wtf", "config.yml")
|
||||
}
|
||||
|
||||
if flags.Version {
|
||||
fmt.Printf("Version: %s\n", version)
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user