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:
parent
9e9ef9371d
commit
ff49ecb082
@ -10,7 +10,7 @@ import (
|
|||||||
// Config is a pointer to the global config object
|
// Config is a pointer to the global config object
|
||||||
var Config *config.Config
|
var Config *config.Config
|
||||||
|
|
||||||
const helpText = `
|
const HelpText = `
|
||||||
Keyboard commands for Git:
|
Keyboard commands for Git:
|
||||||
|
|
||||||
/: Show/hide this help window
|
/: Show/hide this help window
|
||||||
@ -132,7 +132,7 @@ func (widget *Widget) showHelp() {
|
|||||||
widget.app.SetFocus(widget.View)
|
widget.app.SetFocus(widget.View)
|
||||||
}
|
}
|
||||||
|
|
||||||
modal := wtf.NewBillboardModal(helpText, closeFunc)
|
modal := wtf.NewBillboardModal(HelpText, closeFunc)
|
||||||
|
|
||||||
widget.pages.AddPage("help", modal, false, true)
|
widget.pages.AddPage("help", modal, false, true)
|
||||||
widget.app.SetFocus(modal)
|
widget.app.SetFocus(modal)
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
// Config is a pointer to the global config object
|
// Config is a pointer to the global config object
|
||||||
var Config *config.Config
|
var Config *config.Config
|
||||||
|
|
||||||
const helpText = `
|
const HelpText = `
|
||||||
Keyboard commands for Github:
|
Keyboard commands for Github:
|
||||||
|
|
||||||
/: Show/hide this help window
|
/: Show/hide this help window
|
||||||
@ -135,7 +135,7 @@ func (widget *Widget) showHelp() {
|
|||||||
widget.app.SetFocus(widget.View)
|
widget.app.SetFocus(widget.View)
|
||||||
}
|
}
|
||||||
|
|
||||||
modal := wtf.NewBillboardModal(helpText, closeFunc)
|
modal := wtf.NewBillboardModal(HelpText, closeFunc)
|
||||||
|
|
||||||
widget.pages.AddPage("help", modal, false, true)
|
widget.pages.AddPage("help", modal, false, true)
|
||||||
widget.app.SetFocus(modal)
|
widget.app.SetFocus(modal)
|
||||||
|
34
help/help.go
34
help/help.go
@ -3,6 +3,12 @@ package help
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"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) {
|
func DisplayCommandInfo(args []string, version string) {
|
||||||
@ -14,15 +20,20 @@ func DisplayCommandInfo(args []string, version string) {
|
|||||||
|
|
||||||
switch cmd {
|
switch cmd {
|
||||||
case "help", "--help":
|
case "help", "--help":
|
||||||
DisplayHelpInfo()
|
DisplayHelpInfo(args)
|
||||||
case "version", "--version":
|
case "version", "--version":
|
||||||
DisplayVersionInfo(version)
|
DisplayVersionInfo(version)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func DisplayHelpInfo() {
|
func DisplayHelpInfo(args []string) {
|
||||||
fmt.Println("Help is coming...")
|
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)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,3 +41,20 @@ func DisplayVersionInfo(version string) {
|
|||||||
fmt.Printf("Version: %s\n", version)
|
fmt.Printf("Version: %s\n", version)
|
||||||
os.Exit(0)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
// Config is a pointer to the global config object
|
// Config is a pointer to the global config object
|
||||||
var Config *config.Config
|
var Config *config.Config
|
||||||
|
|
||||||
const helpText = `
|
const HelpText = `
|
||||||
Keyboard commands for Textfile:
|
Keyboard commands for Textfile:
|
||||||
|
|
||||||
/: Show/hide this help window
|
/: Show/hide this help window
|
||||||
@ -91,7 +91,7 @@ func (widget *Widget) showHelp() {
|
|||||||
widget.app.SetFocus(widget.View)
|
widget.app.SetFocus(widget.View)
|
||||||
}
|
}
|
||||||
|
|
||||||
modal := wtf.NewBillboardModal(helpText, closeFunc)
|
modal := wtf.NewBillboardModal(HelpText, closeFunc)
|
||||||
|
|
||||||
widget.pages.AddPage("help", modal, false, true)
|
widget.pages.AddPage("help", modal, false, true)
|
||||||
widget.app.SetFocus(modal)
|
widget.app.SetFocus(modal)
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
// Config is a pointer to the global config object
|
// Config is a pointer to the global config object
|
||||||
var Config *config.Config
|
var Config *config.Config
|
||||||
|
|
||||||
const helpText = `
|
const HelpText = `
|
||||||
Keyboard commands for Todo:
|
Keyboard commands for Todo:
|
||||||
|
|
||||||
/: Show/hide this help window
|
/: Show/hide this help window
|
||||||
@ -221,7 +221,7 @@ func (widget *Widget) showHelp() {
|
|||||||
widget.app.SetFocus(widget.View)
|
widget.app.SetFocus(widget.View)
|
||||||
}
|
}
|
||||||
|
|
||||||
modal := wtf.NewBillboardModal(helpText, closeFunc)
|
modal := wtf.NewBillboardModal(HelpText, closeFunc)
|
||||||
|
|
||||||
widget.pages.AddPage("help", modal, false, true)
|
widget.pages.AddPage("help", modal, false, true)
|
||||||
widget.app.SetFocus(modal)
|
widget.app.SetFocus(modal)
|
||||||
|
@ -13,12 +13,12 @@ import (
|
|||||||
// Config is a pointer to the global config object.
|
// Config is a pointer to the global config object.
|
||||||
var Config *config.Config
|
var Config *config.Config
|
||||||
|
|
||||||
const helpText = `
|
const HelpText = `
|
||||||
Keyboard commands for Weather:
|
Keyboard commands for Weather:
|
||||||
|
|
||||||
/: Show/hide this help window
|
/: Show/hide this help window
|
||||||
h: Previous weather location
|
h: Previous weather location
|
||||||
l: Next weather location
|
l: Next weather location
|
||||||
|
|
||||||
arrow left: Previous weather location
|
arrow left: Previous weather location
|
||||||
arrow right: Next weather location
|
arrow right: Next weather location
|
||||||
@ -244,7 +244,7 @@ func (widget *Widget) showHelp() {
|
|||||||
widget.app.SetFocus(widget.View)
|
widget.app.SetFocus(widget.View)
|
||||||
}
|
}
|
||||||
|
|
||||||
modal := wtf.NewBillboardModal(helpText, closeFunc)
|
modal := wtf.NewBillboardModal(HelpText, closeFunc)
|
||||||
|
|
||||||
widget.pages.AddPage("help", modal, false, true)
|
widget.pages.AddPage("help", modal, false, true)
|
||||||
widget.app.SetFocus(modal)
|
widget.app.SetFocus(modal)
|
||||||
|
8
wtf.go
8
wtf.go
@ -119,8 +119,8 @@ func main() {
|
|||||||
/*
|
/*
|
||||||
This allows the user to pass flags in however they prefer. It supports the likes of:
|
This allows the user to pass flags in however they prefer. It supports the likes of:
|
||||||
|
|
||||||
wtf help | -help | --help
|
wtf -help | --help
|
||||||
wtf version | -version | --version
|
wtf -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")
|
||||||
@ -129,14 +129,14 @@ func main() {
|
|||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *flagHelp {
|
if *flagHelp {
|
||||||
help.DisplayHelpInfo()
|
help.DisplayHelpInfo(flag.Args())
|
||||||
}
|
}
|
||||||
|
|
||||||
if *flagVers {
|
if *flagVers {
|
||||||
help.DisplayVersionInfo(version)
|
help.DisplayVersionInfo(version)
|
||||||
}
|
}
|
||||||
|
|
||||||
help.DisplayCommandInfo(flag.Args(), version)
|
//help.DisplayCommandInfo(flag.Args(), version)
|
||||||
|
|
||||||
/* -------------------- end flag parsing and handling -------------------- */
|
/* -------------------- end flag parsing and handling -------------------- */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user