mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-30 18:53:30 +00:00
Bot: Prettier help formatting
This commit is contained in:
parent
70ace8e5e4
commit
aa53661b60
|
@ -281,8 +281,13 @@ func (ctx *Context) callMessageCreate(mc *gateway.MessageCreateEvent) error {
|
||||||
})
|
})
|
||||||
|
|
||||||
case cmd.Arguments[0].custom != nil:
|
case cmd.Arguments[0].custom != nil:
|
||||||
// For consistent behavior, clear the subcommand name off:
|
var pad = len(cmd.Command)
|
||||||
content = content[len(sub.Command):]
|
if len(sub.Command) > 0 { // if this is also a subcommand:
|
||||||
|
pad += len(sub.Command) + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// For consistent behavior, clear the subcommand (and command) name off:
|
||||||
|
content = content[pad:]
|
||||||
// Trim space if there are any:
|
// Trim space if there are any:
|
||||||
content = strings.TrimSpace(content)
|
content = strings.TrimSpace(content)
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,17 @@ var (
|
||||||
}()
|
}()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// HelpUnderline formats command arguments with an underline, similar to
|
||||||
|
// manpages.
|
||||||
|
var HelpUnderline = true
|
||||||
|
|
||||||
|
func underline(word string) string {
|
||||||
|
if HelpUnderline {
|
||||||
|
return "__" + word + "__"
|
||||||
|
}
|
||||||
|
return word
|
||||||
|
}
|
||||||
|
|
||||||
// Subcommand is any form of command, which could be a top-level command or a
|
// Subcommand is any form of command, which could be a top-level command or a
|
||||||
// subcommand.
|
// subcommand.
|
||||||
//
|
//
|
||||||
|
@ -212,7 +223,7 @@ func (sub *Subcommand) Help(indent string, hideAdmin bool) string {
|
||||||
var header string
|
var header string
|
||||||
|
|
||||||
if sub.Command != "" {
|
if sub.Command != "" {
|
||||||
header += sub.Command
|
header += "**" + sub.Command + "**"
|
||||||
}
|
}
|
||||||
|
|
||||||
if sub.Description != "" {
|
if sub.Description != "" {
|
||||||
|
@ -233,15 +244,20 @@ func (sub *Subcommand) Help(indent string, hideAdmin bool) string {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if sub.Command != "" {
|
switch {
|
||||||
|
case sub.Command != "" && cmd.Command != "":
|
||||||
commands += indent + sub.Command + " " + cmd.Command
|
commands += indent + sub.Command + " " + cmd.Command
|
||||||
} else {
|
case sub.Command != "":
|
||||||
|
commands += indent + sub.Command
|
||||||
|
default:
|
||||||
commands += indent + cmd.Command
|
commands += indent + cmd.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch usage := cmd.Usage(); {
|
||||||
case len(cmd.Usage()) > 0:
|
case len(usage) > 0:
|
||||||
commands += " **" + strings.Join(cmd.Usage(), " ") + "**"
|
for _, usage := range usage {
|
||||||
|
commands += " " + underline(usage)
|
||||||
|
}
|
||||||
case cmd.Description != "":
|
case cmd.Description != "":
|
||||||
commands += ": " + cmd.Description
|
commands += ": " + cmd.Description
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue