feat: page command defaults to TOC-only, adds --complete flag
All checks were successful
Integration Tests / test (pull_request) Successful in 30s

This commit was merged in pull request #4.
This commit is contained in:
2026-03-06 02:28:13 +00:00
parent efc227ac90
commit 21a0ae09e2
2 changed files with 22 additions and 7 deletions

View File

@@ -12,15 +12,18 @@ import (
func newPageCmd() *cobra.Command {
var pageSection string
var complete bool
cmd := &cobra.Command{
Use: "page <title>",
Short: "Fetch and display a wiki page",
Long: `Fetches a wiki page and renders it as markdown. Optionally filter
to a specific section.
Long: `Fetches a wiki page and renders its table of contents by default.
Use --section to get a specific section, or --complete for the full page.
Examples:
rsw osrs page "Dragon scimitar"
rsw osrs page "Dragon scimitar" --section "Combat styles"
rsw osrs page "Mining" --complete
rsw rs3 page "Mining" --section "Training"`,
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
@@ -74,13 +77,19 @@ Examples:
md.HR()
}
md.Line(htmlconv.Convert(page.HTML))
if complete {
md.Line(htmlconv.Convert(page.HTML))
} else {
md.Line("Use --section <name> to fetch a specific section, or --complete for the full page.")
}
fmt.Print(md.String())
return nil
},
}
cmd.Flags().StringVar(&pageSection, "section", "", "Fetch only the named section")
cmd.Flags().BoolVar(&complete, "complete", false, "Fetch the complete page content (default shows TOC only)")
return cmd
}

View File

@@ -37,9 +37,14 @@ The first argument is always the game: `osrs` or `rs3`.
Full-text search across wiki pages. Returns ranked titles with snippets.
Use this to find the right page name before fetching details.
### rsw <game> page <title> [--section <name>]
Fetch a wiki page as cleaned markdown. Use `--section` to get just one section
(e.g., "Drops", "Strategy", "Requirements"). Use `--raw` for raw wikitext.
### rsw <game> page <title> [--section <name>] [--complete]
Fetch a wiki page. By default, returns only the table of contents (section list)
to conserve context. Use `--section` to fetch a specific section (e.g., "Drops",
"Strategy", "Requirements"). Use `--complete` for the full page content.
Use `--raw` for raw wikitext.
**Recommended workflow:** First call `page` (no flags) to see available sections,
then call `page --section <name>` to fetch only what you need.
### rsw <game> item <name> [--ironman]
The workhorse for "where do I find X" questions. Returns:
@@ -87,7 +92,8 @@ When a user asks a RuneScape question, think about which command(s) to combine:
`rsw osrs price "abyssal whip"`
**"What's a good money maker at 80 combat?"**
`rsw osrs search "money making"` → then `rsw osrs page "Money making guide"`
`rsw osrs search "money making"` → then `rsw osrs page "Money making guide"` (TOC)
→ then `rsw osrs page "Money making guide" --section "Combat"` for relevant section
### Inferring the game