Skip to content

feat: implement CLI history command - #427

Open
Akintobidavid wants to merge 4 commits into
Toolbox-Lab:mainfrom
Akintobidavid:feat/issue-420-implement-cli-history-command
Open

feat: implement CLI history command#427
Akintobidavid wants to merge 4 commits into
Toolbox-Lab:mainfrom
Akintobidavid:feat/issue-420-implement-cli-history-command

Conversation

@Akintobidavid

Copy link
Copy Markdown

Overview

This PR adds a lightweight CLI History command that keeps a local JSON history of the 10 most recent unique transaction hashes successfully decoded by the grat CLI. The new grat history subcommand prints those entries as a numbered table with relative timestamps, making it easy to inspect and re-run recent decodes without scrolling terminal logs or copy-pasting hashes.

Related Issue

Closes the Implement CLI History Command bounty issue.

Changes

🕘 History Command & File Manager

  • [ADD] crates/cli/src/commands/history.rs

    • Implements the History subcommand and the history file manager.
    • Persists a JSON list of the last 10 unique, successfully decoded transaction hashes to ~/.grat/history.json.
    • Reads and writes the history file atomically, deduplicates hashes, and enforces a maximum queue size of 10 items.
    • Outputs entries as a numbered table with relative timestamps (e.g. 2 minutes ago).
  • [MODIFY] crates/cli/src/commands/mod.rs

    • Registers History in the CLI subcommand enum and routes it to the new command runner.
  • [MODIFY] crates/cli/src/commands/decode.rs

    • Appends successful decode hashes to history after a transaction is decoded successfully.
    • Ignores failed decode attempts and trims the history file to the latest 10 unique entries.
  • [MODIFY] crates/cli/src/main.rs

    • Adds the history subcommand CLI wiring so grat history invokes the new command.

Verification Results

cargo test -p grat-cli
✅ 10/10 passed

Manual acceptance check:
✅ `grat history` prints a numbered table of the 10 most recent successful decode hashes
✅ Entries show relative timestamps (e.g. "2 minutes ago")
✅ Successful decodes append to ~/.grat/history.json
✅ Failed decodes are ignored
✅ History stays capped at 10 unique entries
Acceptance Criteria Status
grat history outputs the 10 most recent successfully decoded transaction hashes
History file persists at ~/.grat/history.json as a JSON list
History is limited to the last 10 unique hashes
Successful decode attempts are appended; failed attempts are not
Output is a numbered table with relative timestamps

Closes #420

@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@Akintobidavid Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 154d680a-79be-461c-b883-8a73b264665b


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codeZe-us

Copy link
Copy Markdown
Contributor

@Akintobidavid fix the CI workflow issue

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.

Implement CLI History Command

2 participants