mirror of
				https://github.com/taigrr/wtf
				synced 2025-01-18 04:03:14 -08:00 
			
		
		
		
	Move the help code into it's own module
This commit is contained in:
		
							parent
							
								
									27107fcd37
								
							
						
					
					
						commit
						c1dd08d594
					
				
							
								
								
									
										32
									
								
								help/help.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								help/help.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					package help
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func DisplayCommandInfo(args []string, version string) {
 | 
				
			||||||
 | 
						if len(args) == 0 {
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cmd := args[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						switch cmd {
 | 
				
			||||||
 | 
						case "help", "--help":
 | 
				
			||||||
 | 
							DisplayHelpInfo()
 | 
				
			||||||
 | 
						case "version", "--version":
 | 
				
			||||||
 | 
							DisplayVersionInfo(version)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func DisplayHelpInfo() {
 | 
				
			||||||
 | 
						fmt.Println("Help is coming...")
 | 
				
			||||||
 | 
						os.Exit(0)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func DisplayVersionInfo(version string) {
 | 
				
			||||||
 | 
						fmt.Printf("Version: %s\n", version)
 | 
				
			||||||
 | 
						os.Exit(0)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										55
									
								
								wtf.go
									
									
									
									
									
								
							
							
						
						
									
										55
									
								
								wtf.go
									
									
									
									
									
								
							@ -2,7 +2,7 @@ package main
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"flag"
 | 
						"flag"
 | 
				
			||||||
	"fmt"
 | 
						//"fmt"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -14,6 +14,7 @@ import (
 | 
				
			|||||||
	"github.com/senorprogrammer/wtf/gcal"
 | 
						"github.com/senorprogrammer/wtf/gcal"
 | 
				
			||||||
	"github.com/senorprogrammer/wtf/git"
 | 
						"github.com/senorprogrammer/wtf/git"
 | 
				
			||||||
	"github.com/senorprogrammer/wtf/github"
 | 
						"github.com/senorprogrammer/wtf/github"
 | 
				
			||||||
 | 
						"github.com/senorprogrammer/wtf/help"
 | 
				
			||||||
	"github.com/senorprogrammer/wtf/jira"
 | 
						"github.com/senorprogrammer/wtf/jira"
 | 
				
			||||||
	"github.com/senorprogrammer/wtf/newrelic"
 | 
						"github.com/senorprogrammer/wtf/newrelic"
 | 
				
			||||||
	"github.com/senorprogrammer/wtf/opsgenie"
 | 
						"github.com/senorprogrammer/wtf/opsgenie"
 | 
				
			||||||
@ -28,30 +29,30 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* -------------------- Built-in Support Documentation -------------------- */
 | 
					/* -------------------- Built-in Support Documentation -------------------- */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func displayCommandInfo(args []string) {
 | 
					//func displayCommandInfo(args []string) {
 | 
				
			||||||
	if len(args) == 0 {
 | 
					//if len(args) == 0 {
 | 
				
			||||||
		return
 | 
					//return
 | 
				
			||||||
	}
 | 
					//}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd := args[0]
 | 
					//cmd := args[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch cmd {
 | 
					//switch cmd {
 | 
				
			||||||
	case "help", "--help":
 | 
					//case "help", "--help":
 | 
				
			||||||
		displayHelpInfo()
 | 
					//displayHelpInfo()
 | 
				
			||||||
	case "version", "--version":
 | 
					//case "version", "--version":
 | 
				
			||||||
		displayVersionInfo()
 | 
					//displayVersionInfo()
 | 
				
			||||||
	}
 | 
					//}
 | 
				
			||||||
}
 | 
					//}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func displayHelpInfo() {
 | 
					//func displayHelpInfo() {
 | 
				
			||||||
	fmt.Println("Help is coming...")
 | 
					//fmt.Println("Help is coming...")
 | 
				
			||||||
	os.Exit(0)
 | 
					//os.Exit(0)
 | 
				
			||||||
}
 | 
					//}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func displayVersionInfo() {
 | 
					//func displayVersionInfo() {
 | 
				
			||||||
	fmt.Printf("Version: %s\n", version)
 | 
					//fmt.Printf("Version: %s\n", version)
 | 
				
			||||||
	os.Exit(0)
 | 
					//os.Exit(0)
 | 
				
			||||||
}
 | 
					//}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* -------------------- Functions -------------------- */
 | 
					/* -------------------- Functions -------------------- */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -141,6 +142,10 @@ var (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func main() {
 | 
					func main() {
 | 
				
			||||||
 | 
						// This all allows the user to pass flags in however they prefer. It supports the likes
 | 
				
			||||||
 | 
						// of:
 | 
				
			||||||
 | 
						//      wtf help    | -help    | --help
 | 
				
			||||||
 | 
						//      wtf version | -version | --version
 | 
				
			||||||
	flagConf := flag.String("config", "~/.wtf/config.yml", "Path to config file")
 | 
						flagConf := flag.String("config", "~/.wtf/config.yml", "Path to config file")
 | 
				
			||||||
	flagHelp := flag.Bool("help", false, "Show help")
 | 
						flagHelp := flag.Bool("help", false, "Show help")
 | 
				
			||||||
	flagVers := flag.Bool("version", false, "Show version info")
 | 
						flagVers := flag.Bool("version", false, "Show version info")
 | 
				
			||||||
@ -148,17 +153,19 @@ func main() {
 | 
				
			|||||||
	flag.Parse()
 | 
						flag.Parse()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if *flagHelp {
 | 
						if *flagHelp {
 | 
				
			||||||
		displayHelpInfo()
 | 
							help.DisplayHelpInfo()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if *flagVers {
 | 
						if *flagVers {
 | 
				
			||||||
		displayVersionInfo()
 | 
							help.DisplayVersionInfo(version)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	displayCommandInfo(flag.Args())
 | 
						help.DisplayCommandInfo(flag.Args(), version)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* -------------------- end flag parsing and handling -------------------- */
 | 
						/* -------------------- end flag parsing and handling -------------------- */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Responsible for creating the configuration directory and default
 | 
				
			||||||
 | 
						// configuration file if they don't already exist
 | 
				
			||||||
	wtf.CreateConfigDir()
 | 
						wtf.CreateConfigDir()
 | 
				
			||||||
	wtf.WriteConfigFile()
 | 
						wtf.WriteConfigFile()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user