Skip to content

Add question, answers, answer, article, user, search commands#1

Open
tamnd wants to merge 3 commits into
mainfrom
feature/question-user-article
Open

Add question, answers, answer, article, user, search commands#1
tamnd wants to merge 3 commits into
mainfrom
feature/question-user-article

Conversation

@tamnd

@tamnd tamnd commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Six new gated commands behind --cookie / ZHIHU_COOKIE: question, answers, answer, article, user, search
  • Upgrades any-cli/kit from v0.2.0 to v0.4.0
  • Refactors library into separate api.go, wire.go, ids.go, ops.go files
  • Adds cookie threading: --cookie flag + ZHIHU_COOKIE env → kit.Config.Extra["cookie"]Config.CookieCookie + Authorization: Bearer headers
  • Rewrites all docs to cover all 8 commands, cookie setup, ID parsing, output formats, exit codes
  • Adds release notes for v0.1.0 and v0.1.1

Test plan

  • go test ./... passes (all 25 tests green)
  • go build ./... passes (CGO_ENABLED=0)
  • zhihu hot fetches live data without cookie
  • zhihu suggest 人工智能 returns suggestions
  • zhihu question <id> with cookie returns question fields
  • zhihu question <id> without cookie exits 4
  • zhihu answers <id> with cookie returns list
  • zhihu answer <id> with cookie returns single answer
  • zhihu article <id> with cookie returns article
  • zhihu user <token> with cookie returns profile
  • zhihu search <query> with cookie returns results

tamnd added 3 commits June 15, 2026 18:46
Six gated commands behind --cookie/ZHIHU_COOKIE, reading Zhihu v4 API
endpoints for question detail, answer lists, single answers, column articles,
user profiles, and search. Also upgrades kit to v0.4.0, refactors the library
into api/wire/ids/ops files, and rewrites all docs.
- HotItem now carries excerpt and followers (follower_count)
- Question carries excerpt, author_token, and a topics list ([]string)
- Answer carries excerpt; URL falls back to /answer/{id} when question ID is absent
- Article carries excerpt
- User carries thanked and avatar_url
- SearchResult carries author, author_token, and votes
- Wire converters updated to populate the new fields
- include params updated to request the new fields from the v4 API
- Fix double URL-encoding in suggest (ops.go passed QueryEscape output to
  api.go which encoded again; now plain string passes through)
- Rewrite guides/adding-a-command.md and guides/resource-uris.md with real
  Zhihu content instead of generic scaffold copy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant