mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Closes #72. --info flag displays module help text
Usage: wtf -i=todo wtf --info=todo
This commit is contained in:
parent
ebf900e91b
commit
f13abc9ed3
5
wtf.go
5
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
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user