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
}