cli #1
@ -8,35 +8,37 @@ import (
|
|||||||
|
|
||||||
type ProgramFunction func() error
|
type ProgramFunction func() error
|
||||||
type Program struct {
|
type Program struct {
|
||||||
Name string
|
Name string
|
||||||
Function ProgramFunction
|
Function ProgramFunction
|
||||||
Description string
|
ShortDescription string
|
||||||
}
|
}
|
||||||
|
|
||||||
var HelpHeader = `Meow
|
var HelpHeader = `This is the help page of transfem-startpage.
|
||||||
Ze
|
transfem-startpage {program} {...args}
|
||||||
Dong`
|
The following Programs are available:`
|
||||||
var Programs = []Program{
|
var Programs = []Program{
|
||||||
{
|
{
|
||||||
Name: "help",
|
Name: "help",
|
||||||
Function: Help,
|
ShortDescription: "get more information on how the cli in general or a specific program works",
|
||||||
Description: "get more information on how the cli or a program works",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "start",
|
Name: "start",
|
||||||
Function: Start,
|
Function: Start,
|
||||||
Description: "start the webserver",
|
ShortDescription: "start the webserver",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "cache",
|
Name: "cache",
|
||||||
Function: Cache,
|
Function: Cache,
|
||||||
Description: "do something with the cache",
|
ShortDescription: "do something with the cache",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func Cli() {
|
func Cli() {
|
||||||
fmt.Println("running transfem startpage")
|
fmt.Println("running transfem startpage")
|
||||||
|
|
||||||
|
// getting around initialization cycle
|
||||||
|
Programs[0].Function = Help
|
||||||
|
|
||||||
programName := "help"
|
programName := "help"
|
||||||
if len(os.Args) > 1 {
|
if len(os.Args) > 1 {
|
||||||
programName = os.Args[1]
|
programName = os.Args[1]
|
||||||
|
@ -1,8 +1,21 @@
|
|||||||
package cli
|
package cli
|
||||||
|
|
||||||
import "log"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func generalHelp() error {
|
||||||
|
fmt.Println()
|
||||||
|
fmt.Println(HelpHeader)
|
||||||
|
for _, p := range Programs {
|
||||||
|
fmt.Println(" - " + p.Name + ":\t" + p.ShortDescription)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func Help() error {
|
func Help() error {
|
||||||
log.Println("running help")
|
log.Println("running help")
|
||||||
return nil
|
|
||||||
|
return generalHelp()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user