Skip to content

変更系コマンド(create/update/complete/delete)に --format json を追加 #5

Description

@yancya

全体ロードマップ: https://github.com/yancya/reminder-cli/issues/3(P2-5)

背景

list / show--format text|json|pretty-json|yaml を持つが、変更系(create / update / complete / delete)は絵文字付きテキストのみ。このため reminder-server は create の出力を正規表現 /ID: ([A-F0-9\-]+)/ でパースして ID を拾っており、出力文言を1文字変えただけで壊れる。変更系にも機械可読な出力を追加する。

現状ポインタ

  • Sources/reminder-cli/reminder_cli.swiftCreate(158行〜) / Update(206行〜) / Delete(285行〜) / Complete(337行〜) に --format オプションなし。List(66行〜) / Show(98行〜) には既にある
  • Sources/reminder-cli/OutputFormatter.swiftoutput(reminder:) が単体 Reminder の全フォーマット出力を既に実装済み(再利用できる)
  • Sources/reminder-cli/ReminderStore.swift — 各操作の実装。操作後の EKReminder から ReminderOutput を組み立てて返せるようにする

ゴールと受け入れ条件

  • create / update / complete--format text|json|pretty-json|yaml を追加し、json 系では操作後の Reminder 全体(id, title, listName, isCompleted, priority, dates, notes, url, alarms)を stdout に出力する
  • delete --format json{"deleted": true, "id": "...", "title": "..."} 相当の確認オブジェクトを出力する
  • 後方互換: --format 未指定時のテキスト出力は現行と完全一致(既存の絵文字メッセージを一切変更しない)
  • --format json 時、確認プロンプト等の人間向けメッセージは stdout に混ぜない(delete の確認は従来通り。JSON は結果のみ)
  • テストで各フォーマットの出力を検証(テスト基盤 issue に依存。未導入なら先にそちらを実施)
  • バージョンを 1.1.0 に上げ、README の各コマンド例に --format json を追記

手順

  • TDD: OutputFormatter 側の期待出力テストを先に書く
  • ReminderStore の create/update/complete が操作後の ReminderOutput を返すようリファクタ
  • 各コマンドに @Option var format: OutputFormat = .text を追加し、text 時は従来コード、それ以外は OutputFormatter.output(reminder:) に委譲
  • delete 用の確認オブジェクト出力を実装
  • README・バージョン更新(CLAUDE.md の RC ワークフローに従い 1.1.0-rc1 から開始)

関連

  • reminder-server 側の追従 issue(正規表現パース廃止)はこの issue の完了後に着手する

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions