[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/cli/RFC.md fully. Find features des... #65

Merged
Virgil merged 1 commit from agent/read---spec-code-core-go-cli-rfc-md-full into dev 2026-04-02 10:11:46 +00:00
2 changed files with 34 additions and 10 deletions
Showing only changes of commit 7bf060986d - Show all commits

View file

@ -2,6 +2,7 @@ package help
import (
"bufio"
"fmt"
"strings"
"forge.lthn.ai/core/cli/pkg/cli"
@ -38,7 +39,10 @@ func AddHelpCommands(root *cli.Command) {
return suggestErr
}
cli.Blank()
renderHelpHint(args[0])
return cli.Err("help topic %q not found", args[0])
}
renderHelpHint(args[0])
return cli.Err("help topic %q not found", args[0])
}
@ -89,6 +93,7 @@ func searchHelpTopics(catalog *gohelp.Catalog, query string) error {
func renderSearchResults(results []*gohelp.SearchResult, query string) error {
if len(results) == 0 {
renderHelpHint(query)
return cli.Err("no help topics matched %q", query)
}
@ -102,6 +107,13 @@ func renderSearchResults(results []*gohelp.SearchResult, query string) error {
return nil
}
func renderHelpHint(query string) {
cli.Hint("browse", "core help")
if trimmed := strings.TrimSpace(query); trimmed != "" {
cli.Hint("search", fmt.Sprintf("core help search %q", trimmed))
}
}
func renderTopicList(topics []*gohelp.Topic) error {
if len(topics) == 0 {
return cli.Err("no help topics available")

View file

@ -161,9 +161,28 @@ func TestAddHelpCommands_Bad(t *testing.T) {
cmd := newHelpCommand(t)
require.NoError(t, cmd.Flags().Set("search", "zzzyyyxxx"))
err := cmd.RunE(cmd, nil)
require.Error(t, err)
assert.Contains(t, err.Error(), "no help topics matched")
out := captureOutput(t, func() {
err := cmd.RunE(cmd, nil)
require.Error(t, err)
assert.Contains(t, err.Error(), "no help topics matched")
})
assert.Contains(t, out, "browse")
assert.Contains(t, out, "core help")
assert.Contains(t, out, "core help search")
})
t.Run("missing topic without suggestions shows hints", func(t *testing.T) {
cmd := newHelpCommand(t)
out := captureOutput(t, func() {
err := cmd.RunE(cmd, []string{"definitely-not-a-real-topic"})
require.Error(t, err)
assert.Contains(t, err.Error(), "help topic")
})
assert.Contains(t, out, "browse")
assert.Contains(t, out, "core help")
})
t.Run("missing search query", func(t *testing.T) {
@ -179,13 +198,6 @@ func TestAddHelpCommands_Bad(t *testing.T) {
assert.Contains(t, err.Error(), "help search query is required")
})
t.Run("missing topic", func(t *testing.T) {
cmd := newHelpCommand(t)
err := cmd.RunE(cmd, []string{"definitely-not-a-real-topic"})
require.Error(t, err)
assert.Contains(t, err.Error(), "help topic")
})
t.Run("missing topic shows suggestions when available", func(t *testing.T) {
query := searchableHelpQuery(t)