1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Closes #29. wtf.go --help [module name] returns help text if any is available.

This commit is contained in:
Chris Cummer
2018-05-22 20:34:33 -07:00
parent 9e9ef9371d
commit ff49ecb082
7 changed files with 47 additions and 19 deletions

View File

@@ -3,6 +3,12 @@ package help
import (
"fmt"
"os"
"github.com/senorprogrammer/wtf/git"
"github.com/senorprogrammer/wtf/github"
"github.com/senorprogrammer/wtf/textfile"
"github.com/senorprogrammer/wtf/todo"
"github.com/senorprogrammer/wtf/weather"
)
func DisplayCommandInfo(args []string, version string) {
@@ -14,15 +20,20 @@ func DisplayCommandInfo(args []string, version string) {
switch cmd {
case "help", "--help":
DisplayHelpInfo()
DisplayHelpInfo(args)
case "version", "--version":
DisplayVersionInfo(version)
}
}
func DisplayHelpInfo() {
fmt.Println("Help is coming...")
func DisplayHelpInfo(args []string) {
if len(args) >= 1 {
fmt.Printf("%s\n", helpFor(args[0]))
} else {
fmt.Println("\n --help takes a module name as an argument, i.e: '--help github'")
}
os.Exit(0)
}
@@ -30,3 +41,20 @@ func DisplayVersionInfo(version string) {
fmt.Printf("Version: %s\n", version)
os.Exit(0)
}
func helpFor(moduleName string) string {
switch moduleName {
case "git":
return git.HelpText
case "github":
return github.HelpText
case "textfile":
return textfile.HelpText
case "todo":
return todo.HelpText
case "weather":
return weather.HelpText
default:
return fmt.Sprintf("\n There is no help available for '%s'", moduleName)
}
}