diff --git a/wtf.go b/wtf.go index ab649fc7..8329bcbd 100644 --- a/wtf.go +++ b/wtf.go @@ -15,6 +15,7 @@ import ( "github.com/senorprogrammer/wtf/gcal" "github.com/senorprogrammer/wtf/git" "github.com/senorprogrammer/wtf/github" + "github.com/senorprogrammer/wtf/help" "github.com/senorprogrammer/wtf/jira" "github.com/senorprogrammer/wtf/newrelic" "github.com/senorprogrammer/wtf/opsgenie" @@ -202,6 +203,10 @@ func main() { cmdFlags := wtf.NewCommandFlags() cmdFlags.Parse(version) + if cmdFlags.HasInfo() { + help.DisplayHelpInfo(cmdFlags.Info) + } + /* -------------------- end flag parsing and handling -------------------- */ // Responsible for creating the configuration directory and default diff --git a/wtf/command_flags.go b/wtf/command_flags.go index 9163634e..f876d8de 100644 --- a/wtf/command_flags.go +++ b/wtf/command_flags.go @@ -10,6 +10,7 @@ import ( type CommandFlags struct { Config string `short:"c" long:"config" optional:"yes" description:"Path to config file"` + Info string `short:"i" long:"info" optional:"yes" description:"Display info about the specified module"` Version bool `short:"v" long:"version" description:"Show Version Info"` } @@ -20,6 +21,14 @@ func NewCommandFlags() *CommandFlags { /* -------------------- Exported Functions -------------------- */ +func (cmdFlags *CommandFlags) HasConfig() bool { + return len(cmdFlags.Config) > 0 +} + +func (cmdFlags *CommandFlags) HasInfo() bool { + return len(cmdFlags.Info) > 0 +} + func (cmdFlags *CommandFlags) Parse(version string) { parser := flags.NewParser(cmdFlags, flags.Default) if _, err := parser.Parse(); err != nil { @@ -28,14 +37,13 @@ func (cmdFlags *CommandFlags) Parse(version string) { } } - if len(cmdFlags.Config) == 0 { + if !cmdFlags.HasConfig() { homeDir, err := Home() if err != nil { os.Exit(1) } cmdFlags.Config = filepath.Join(homeDir, ".wtf", "config.yml") - fmt.Printf(">> A: %s\n", cmdFlags.Config) } if cmdFlags.Version { diff --git a/wtf/config_files.go b/wtf/config_files.go index 1dbf86e5..ff57654d 100644 --- a/wtf/config_files.go +++ b/wtf/config_files.go @@ -59,8 +59,6 @@ func CreateFile(fileName string) (string, error) { // LoadConfigFile loads the config.yml file to configure the app func LoadConfigFile(filePath string) *config.Config { - fmt.Printf(">> B: %s\n", filePath) - absPath, _ := ExpandHomeDir(filePath) cfg, err := config.ParseYamlFile(absPath)