ข้ามไปเนื้อหาหลัก

● กำลังพัฒนา

RSS Reader CLI

CLI tool สำหรับอ่าน RSS feeds ใน terminal — ดึง feed, แสดงบทความล่าสุด, บันทึก source ไว้ใน config

· อ่านประมาณ 2 นาที

สารบัญ

ปัญหาที่แก้

อ่าน blog และ changelog ของ library ที่ติดตามอยู่ผ่าน RSS แต่ไม่อยากเปิด browser ทุกครั้ง ต้องการอ่านใน terminal ระหว่างทำงาน


สิ่งที่ทำได้

# เพิ่ม feed
rss add https://astro.build/rss.xml --name "Astro"
rss add https://bun.sh/blog/rss --name "Bun"

# ดูรายการ feeds
rss list

# อ่านบทความล่าสุด (แสดง 5 อันจากทุก feed)
rss read

# อ่านจาก feed เดียว
rss read --source astro --limit 10

# เปิดบทความใน browser
rss open 3

Stack

  • Node.js + TypeScript — เขียน type-safe ตั้งแต่ต้น
  • commander.js — parse CLI arguments และ subcommands
  • fast-xml-parser — parse XML ของ RSS/Atom feeds
  • node-fetch — fetch feed URLs
  • ~/.config/rss-cli/feeds.json — เก็บรายการ feeds ใน JSON

โครงสร้างโปรเจค

rss-reader-cli/
├── src/
│   ├── commands/
│   │   ├── add.ts      # เพิ่ม feed
│   │   ├── list.ts     # แสดงรายการ
│   │   ├── read.ts     # ดึงและแสดงบทความ
│   │   └── open.ts     # เปิดใน browser
│   ├── lib/
│   │   ├── config.ts   # อ่าน/เขียน config file
│   │   └── fetcher.ts  # fetch + parse RSS/Atom
│   └── index.ts        # main entry + commander setup
├── package.json
└── tsconfig.json

ตัวอย่าง Output

🔵 Astro Blog · 3 new
  [1] Astro 5.8 Release Notes — 2 hours ago
  [2] View Transitions API improvements — 1 day ago
  [3] Server Islands: What's next — 3 days ago

🟢 Bun · 1 new
  [4] Bun v1.2.15 — 5 hours ago

──────────────────────────────
Run `rss open <number>` to open in browser

สิ่งที่เรียนรู้

  • parse XML ที่ไม่สม่ำเสมอ (RSS 2.0 vs Atom 1.0 format ต่างกัน)
  • จัดการ encoding ใน XML — บาง feed ใช้ CDATA บาง feed ใช้ HTML entities
  • อ่าน/เขียน config file ที่ user home directory อย่าง idiomatic

สิ่งที่จะทำต่อ

  • Filter บทความที่อ่านแล้ว (track read items ใน config)
  • Support OPML import/export
  • Preview สรุปบทความแบบ inline (ดึง og:description)
  • Publish เป็น npm package