mirror of
https://github.com/tiennm99/tiennm99bot.git
synced 2026-10-15 04:19:02 +00:00
fix(commands): remove examples from command discovery
This commit is contained in:
1 parent
b5c7427520
commit
a211b7f8b7
22 files changed
+47
-154
No files matched your search
@@ -50,9 +50,6 @@ func RenderHelp(reg *modules.Registry) string {
|
||||
fmt.Fprintf(&sb, "\n%s %s",
|
||||
html.EscapeString(command.InvocationSentence()),
|
||||
html.EscapeString(command.SummarySentence()))
|
||||
if example := command.ExampleInvocation(); example != "" {
|
||||
fmt.Fprintf(&sb, " Eg: <code>%s</code>", html.EscapeString(example))
|
||||
}
|
||||
}
|
||||
sections = append(sections, sb.String())
|
||||
}
|
||||
|
||||
@@ -74,13 +74,12 @@ func TestRenderHelp_GroupsByModuleAndSkipsNonPublic(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderHelp_ShowsParametersAndCopyableExample(t *testing.T) {
|
||||
func TestRenderHelp_ShowsParametersWithoutExample(t *testing.T) {
|
||||
command := modules.Command{
|
||||
Name: "buy",
|
||||
Visibility: modules.VisibilityPublic,
|
||||
Description: "Buy & hold",
|
||||
Parameters: "<quantity> <ticker>",
|
||||
Example: "/buy 100 TCB & hold",
|
||||
Handler: helpTestNoop,
|
||||
}
|
||||
reg, err := modules.Build(
|
||||
@@ -97,14 +96,8 @@ func TestRenderHelp_ShowsParametersAndCopyableExample(t *testing.T) {
|
||||
if !strings.Contains(out, "/buy <quantity> <ticker>. Buy & hold.") {
|
||||
t.Fatalf("help missing formatted invocation and summary:\n%s", out)
|
||||
}
|
||||
if !strings.Contains(out, "<code>/buy 100 TCB & hold</code>") {
|
||||
t.Fatalf("help missing copyable example:\n%s", out)
|
||||
}
|
||||
if !strings.Contains(out, "Buy & hold. Eg: <code>/buy 100 TCB & hold</code>") {
|
||||
t.Fatalf("help missing short example label:\n%s", out)
|
||||
}
|
||||
if strings.Contains(out, "<pre>") {
|
||||
t.Fatalf("help example should use inline code, not a pre block:\n%s", out)
|
||||
if strings.Contains(out, "Eg:") || strings.Contains(out, "<code>") || strings.Contains(out, "<pre>") {
|
||||
t.Fatalf("help should not render examples:\n%s", out)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user