Skip to content

feat(output): modernize terminal output with a badges + rules design#227

Merged
hahwul merged 1 commit into
mainfrom
feat/modern-output-design
Jun 24, 2026
Merged

feat(output): modernize terminal output with a badges + rules design#227
hahwul merged 1 commit into
mainfrom
feat/modern-output-design

Conversation

@hahwul

@hahwul hahwul commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

Modernizes jwt-hack's terminal output with a cohesive "badges + rules" design, without changing the stdout data/--json contract. All human-readable framing now flows through a single presentation layer.

What changed

  • New design systemsrc/printing/theme.rs: section headers (▎ DECODE ────), sub-sections (▎ Header), dim-label/accent-value key-value rows, colored severity badges (● PASS / ▲ CRIT / ◆ MED / ■ LOW, and ✓ VALID / ✗ INVALID for jwks), a unified braille spinner and a block-fill progress bar (█▓░).
  • Logger & banner (printing/mod.rs): dropped the [..] [..] bracket noise for a clean dim-time glyph message; compact dot-separated banner identity line.
  • Per-command output restyled: decode, encode, version, payload, scan, jwks, crack.
  • utils log_* + spinner helpers delegate to the theme.
  • Latent bug fixed: width padding ({:<14}) was applied to already-colored strings, so columns drift under a real TTY (the pad counts ANSI escape bytes). Helpers now pad the plain text then color.

Before → After (decode)

  Algorithm     HS256              ▎ DECODE ─────────────────────────
  Type          JWT                  Algorithm     HS256
                            ──►       Type          JWT
  Header
  { ... }                          ▎ Header
                                     { ... }

Contracts preserved (verified)

  • --json output byte-identical to main (machine path untouched; diffs only in pre-existing HashMap key-order + timing fields).
  • Severity::as_str() / its Serialize impl and the HTML report unchanged — badges use a separate display method.
  • ✅ stdout data lines (tokens, payloads, JSON, PEM) stay structurally intact & pipe-safe (encode | tail -1, payload | grep eyJ, decode | grep '"alg"').
  • ✅ Color stays TTY / NO_COLOR gated via colored; badges remain glyph-distinguishable in monochrome (e.g. the shell TUI capture).

Verification

  • cargo fmt --check, cargo clippy --all-targets, cargo build — all clean, zero warnings.
  • cargo test434 passed / 0 failed (incl. new theme unit tests; verified race-free across repeated runs).
  • Ran a multi-agent adversarial review over the diff; all confirmed findings (rustfmt, a flaky-test race, cross-command spacing, doc accuracy, jwks badge width) are fixed in this branch.

🤖 Generated with Claude Code

Introduce a centralized presentation layer (src/printing/theme.rs) and
restyle every human-readable command output to a cohesive "badges + rules"
look: section headers with an accent bar + horizontal rule, dim-label /
accent-value key-value rows, colored severity badges for scan & jwks, and
a unified braille spinner + block-fill progress bar.

- theme: section/subsection headers, kv rows, status badges (badge /
  badge_width), spinner / progress_bar helpers, shared glyph constants.
- Logger & banner refreshed: dropped the "[..] [..]" bracket noise for a
  dim time + glyph line; compact dot-separated identity line in the banner.
- utils log_* and spinner helpers now delegate to the theme.
- Fix a latent alignment bug: width padding was applied to already-colored
  strings (the count includes ANSI escape bytes, so columns drift under a
  real TTY); helpers now pad the plain text and then apply color.

Contracts preserved (verified):
- --json output is byte-identical (the machine-readable path is untouched).
- Severity::as_str() / its Serialize impl and the HTML report are unchanged.
- stdout data lines (tokens, payloads, JSON, PEM) stay structurally intact
  and pipe-safe.
- Color stays TTY / NO_COLOR gated via the `colored` crate.
@hahwul hahwul merged commit 514183c into main Jun 24, 2026
8 checks passed
@hahwul hahwul deleted the feat/modern-output-design branch June 24, 2026 15:18
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.86667% with 158 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/cmd/jwks.rs 0.00% 52 Missing ⚠️
src/cmd/crack.rs 6.66% 42 Missing ⚠️
src/printing/theme.rs 74.73% 24 Missing ⚠️
src/printing/mod.rs 0.00% 18 Missing ⚠️
src/cmd/scan.rs 61.76% 13 Missing ⚠️
src/utils/mod.rs 40.00% 6 Missing ⚠️
src/cmd/decode.rs 91.42% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

2 participants