build: cleanup base build interface.

This commit is contained in:
Alexandre Pujol 2024-09-26 22:05:47 +01:00
parent c6c4920598
commit 6f5604d59d
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
6 changed files with 21 additions and 16 deletions

View file

@ -9,20 +9,20 @@ import "fmt"
type BaseInterface interface {
Message() string
Name() string
Usage() string
Usage() []string
}
type Base struct {
Msg string
Keyword string
Help string
Help []string
}
func (b Base) Name() string {
return b.Keyword
}
func (b Base) Usage() string {
func (b Base) Usage() []string {
return b.Help
}
@ -41,7 +41,9 @@ func Help[T BaseInterface](name string, tasks map[string]T) string {
func Usage[T BaseInterface](name string, tasks map[string]T) string {
res := fmt.Sprintf("%s\n", name)
for _, t := range tasks {
res += fmt.Sprintf(" %s\n", t.Usage())
for _, h := range t.Usage() {
res += fmt.Sprintf(" #aa:%s %s\n", t.Name(), h)
}
}
return res
}