finished general help
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/TwiN/go-color"
|
||||
)
|
||||
|
||||
type ProgramFunction func() error
|
||||
@@ -21,7 +23,7 @@ type Argument struct {
|
||||
}
|
||||
|
||||
var HelpHeader = `This is the help page of transfem-startpage.
|
||||
transfem-startpage {program} {...args}
|
||||
` + color.Bold + `transfem-startpage {program} {...args}` + color.Reset + `
|
||||
The following Programs are available:`
|
||||
var Programs = []Program{
|
||||
{
|
||||
|
||||
@@ -3,13 +3,42 @@ package cli
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/TwiN/go-color"
|
||||
)
|
||||
|
||||
func padString(s string, n int) string {
|
||||
missing := n - len(s)
|
||||
if missing <= 0 {
|
||||
return s
|
||||
}
|
||||
|
||||
for _ = range missing {
|
||||
s = s + " "
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func generalHelp() error {
|
||||
fmt.Println()
|
||||
fmt.Println(HelpHeader)
|
||||
fmt.Println()
|
||||
|
||||
for _, p := range Programs {
|
||||
fmt.Println(" - " + p.Name + ":\t" + p.ShortDescription)
|
||||
fmt.Print(color.Bold + padString(p.Name, 7) + color.Reset)
|
||||
|
||||
argumentString := color.Purple
|
||||
for _, a := range p.Arguments {
|
||||
requiredString := ""
|
||||
if a.Required {
|
||||
requiredString = "*"
|
||||
}
|
||||
argumentString = argumentString + " [" + requiredString + a.Name + ":" + a.Type + "]"
|
||||
}
|
||||
argumentString = argumentString + color.Reset
|
||||
|
||||
fmt.Print(padString(argumentString, 40) + p.ShortDescription + "\n")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user