Files
jackwener__opencli/docs/adapters/browser/reddit.md
jakevin fa9b38cd92 feat(reddit): add whoami, home, subreddit-info read commands (#1491)
* feat(reddit): add whoami, home, subreddit-info read commands

Closes gap against jackwener/rdt-cli — three commands the existing 17 reddit
adapters were missing:

- `reddit whoami` — show the currently logged-in identity (fields:
  Username, ID, Post / Comment / Total Karma, Account Created, Gold, Mod,
  Verified Email, Has Mail, Inbox Count). Probes `/api/me.json` with
  two-pronged auth detection (401/403 OR `data.name` missing on 200 —
  Reddit returns 200 with an empty body for stale anon sessions, see PR
  #1428).

- `reddit home` — personalized Best feed (`/best.json`). Distinct from
  the public `frontpage`/`r/all` command: enforces login via the same
  two-pronged auth check rather than silently degrading to the
  unauthenticated default feed. `--limit` accepts [1, 100] — out-of-range
  raises `ArgumentError` before navigation, no silent clamp.

- `reddit subreddit-info` — subreddit metadata (Name, Title, Subscribers,
  Active Now, NSFW, Type, Description, Created, URL) from
  `/r/<X>/about.json`. Banned / private / quarantined / 404 subreddits
  raise `EmptyResultError` so the output table never holds a silent
  sentinel row.

All three use Strategy.COOKIE + siteSession:'persistent' matching the
existing reddit adapters, validate args upfront before `page.goto`, and
use the 5-kind discriminated-union pattern (kind: auth/http/missing/
exception/ok) from PR #1428 to map page.evaluate results to typed errors
on the Node side. Intermediate object keys deliberately avoid the
declared columns (`field`/`value`/`rank`/etc.) per the silent-column-drop
audit sediment from PR #1329.

Tests: 28 new (whoami 6, home 9, subreddit-info 13); full reddit suite
38/38. Audits: typed-error-lint 189/189 (0 new), silent-column-drop
103/103 (0 new). Manifest 812 → 815.

Refs: https://github.com/jackwener/rdt-cli

* fix(reddit): tighten new read command failure contracts

* fix(reddit): treat inaccessible subreddit info as empty
2026-05-12 04:10:44 +08:00

2.5 KiB

Reddit

Mode: 🔐 Browser · Domain: reddit.com

Commands

Command Description
opencli reddit hot Hot posts from a subreddit (or frontpage if none)
opencli reddit frontpage Frontpage / r/all listing
opencli reddit home Personalized Best feed (requires login)
opencli reddit popular Trending posts on /r/popular
opencli reddit search Search posts
opencli reddit subreddit Posts from a specific subreddit, with sort and time filters
opencli reddit subreddit-info Subreddit metadata (subscribers, active, NSFW, created, description)
opencli reddit read Read a post thread with comments
opencli reddit user View a user profile
opencli reddit user-posts A user's submitted posts
opencli reddit user-comments A user's comments
opencli reddit whoami Show the currently logged-in Reddit identity
opencli reddit upvote Vote on a post or comment
opencli reddit save Save / unsave a post or comment
opencli reddit comment Comment on a post
opencli reddit reply Reply to a comment
opencli reddit subscribe Join / leave a subreddit
opencli reddit saved List your saved items
opencli reddit upvoted List your upvoted posts

Usage Examples

# Quick start
opencli reddit hot --limit 5

# Read one subreddit
opencli reddit subreddit python --limit 10

# Subreddit metadata (subscribers / active / NSFW / created / description)
opencli reddit subreddit-info AskReddit

# Personalized Best feed (requires login)
opencli reddit home --limit 10

# Who am I logged in as?
opencli reddit whoami

# Read a post thread
opencli reddit read 1abc123 --depth 2

# Comment on a post
opencli reddit comment 1abc123 "Great post"

# Reply to a comment
opencli reddit reply okf3s7u "Thanks for the context"

# JSON output
opencli reddit hot -f json

# Verbose mode
opencli reddit hot -v

Auth-required commands

whoami, home, saved, upvoted, subscribe, upvote, save, comment, and reply all require a logged-in reddit.com cookie session. When the session is missing or expired they raise AuthRequiredError (exit code 5) instead of silently returning empty rows.

For subreddit-info, missing / banned / private / quarantined subreddits raise EmptyResultError (exit code 6) so the output table never contains a silent sentinel row.

Prerequisites