mirror of
https://github.com/ipfs/kubo.git
synced 2025-08-06 19:44:01 +08:00
Add logic for copying ShortDes to LongDesc if it is not present
This is the best place for inserting it that I found. Test in #2648 should be modified to run `Root.ProcessHelp()`. License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
@ -258,6 +258,25 @@ func (c *Command) Subcommand(id string) *Command {
|
||||
return c.Subcommands[id]
|
||||
}
|
||||
|
||||
type CommandVisitor func(*Command)
|
||||
|
||||
// Walks tree of all subcommands (including this one)
|
||||
func (c *Command) Walk(visitor CommandVisitor) {
|
||||
visitor(c)
|
||||
for _, cm := range c.Subcommands {
|
||||
cm.Walk(visitor)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Command) ProcessHelp() {
|
||||
c.Walk(func(cm *Command) {
|
||||
ht := &cm.Helptext
|
||||
if len(ht.LongDescription) == 0 {
|
||||
ht.LongDescription = ht.ShortDescription
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// checkArgValue returns an error if a given arg value is not valid for the
|
||||
// given Argument
|
||||
func checkArgValue(v string, found bool, def Argument) error {
|
||||
|
Reference in New Issue
Block a user