-
Notifications
You must be signed in to change notification settings - Fork 0
/
help.go
31 lines (25 loc) · 941 Bytes
/
help.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package conq
import "io/fs"
// HelpSubject represents a command&option-tree node that is subject to a help query.
type HelpSubject struct {
Cmd *Cmd
Opt *O
Ctx *Ctx
}
// Helper provides a helptexts for nodes in the command&options tree.
type Helper interface {
Help(HelpSubject) string
}
// HelpSelector is a func that is used when walking the command-tree to assemble
// only the subjects the selector accepts into the helptext.
type HelpSelector func(*Cmd, HelpSubject, Helper, string) (accept, recurse bool)
// GO AWAY!
// CmdHelp details how this command is to be treated by help/assistance commands
type CmdHelp struct {
// Filter for the subjects that will considered in help-generation.
// An interesting usecase could be to skip non-runnable commands or select for
// a certain depth in the tree.
Select HelpSelector
// Articles contains templates for generating helptexts using cmdhelp.HelpContext.
Articles fs.FS
}