[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/cli/RFC.md fully. Find ONE feature ... #43
2 changed files with 42 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package help
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"strings"
|
||||
|
||||
"forge.lthn.ai/core/cli/pkg/cli"
|
||||
|
|
@ -63,10 +64,34 @@ func renderTopicList(topics []*gohelp.Topic) error {
|
|||
cli.Section("Available Help Topics")
|
||||
for _, topic := range topics {
|
||||
cli.Println(" %s - %s", topic.ID, topic.Title)
|
||||
if summary := topicSummary(topic); summary != "" {
|
||||
cli.Println("%s", cli.DimStr(" "+summary))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func topicSummary(topic *gohelp.Topic) string {
|
||||
if topic == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
content := strings.TrimSpace(topic.Content)
|
||||
if content == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(strings.NewReader(content))
|
||||
for scanner.Scan() {
|
||||
line := strings.TrimSpace(scanner.Text())
|
||||
if line == "" || strings.HasPrefix(line, "#") {
|
||||
continue
|
||||
}
|
||||
return line
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func renderTopic(t *gohelp.Topic) {
|
||||
cli.Blank()
|
||||
cli.Println("%s", cli.TitleStyle.Render(t.Title))
|
||||
|
|
|
|||
|
|
@ -78,6 +78,23 @@ func TestRenderSearchResults_Good(t *testing.T) {
|
|||
assert.Contains(t, out, "Core is configured via environment variables.")
|
||||
}
|
||||
|
||||
func TestRenderTopicList_Good(t *testing.T) {
|
||||
out := captureOutput(t, func() {
|
||||
err := renderTopicList([]*gohelp.Topic{
|
||||
{
|
||||
ID: "config",
|
||||
Title: "Configuration",
|
||||
Content: "# Configuration\n\nCore is configured via environment variables.\n\nMore details follow.",
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
assert.Contains(t, out, "AVAILABLE HELP TOPICS")
|
||||
assert.Contains(t, out, "config - Configuration")
|
||||
assert.Contains(t, out, "Core is configured via environment variables.")
|
||||
}
|
||||
|
||||
func TestAddHelpCommands_Bad(t *testing.T) {
|
||||
t.Run("missing search results", func(t *testing.T) {
|
||||
cmd := newHelpCommand(t)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue