finished general help

This commit is contained in:
Hazel Noack
2025-07-16 11:45:28 +02:00
parent 7f43eb43e0
commit 51b788bb50
4 changed files with 36 additions and 2 deletions

View File

@@ -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{
{

View File

@@ -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
}