Skip to content

refactor: improve usage tips#198

Merged
pi0 merged 6 commits intounjs:mainfrom
kricsleo:refactor/improve-usage-tips
Mar 15, 2026
Merged

refactor: improve usage tips#198
pi0 merged 6 commits intounjs:mainfrom
kricsleo:refactor/improve-usage-tips

Conversation

@kricsleo
Copy link
Copy Markdown
Member

@kricsleo kricsleo commented Apr 8, 2025

resolves #147

This PR aims to enhance the usage tips, making them more readable and less confusing.

  • Added (Default: ...) to descriptions when default: ... is set.
  • Moved (required) from the argument part to the description.
  • Added fallback value hints using snake_case names to avoid confusion when multiple args are displayed together (Improve arg help usage message (placeholder) #147).

Mainly referenced https://clig.dev/

Looking forward to your feedbacks! ❤️

Before After
image image
image image
image image

Summary by CodeRabbit

  • Style
    • Enhanced command-line help text formatting with clearer value indicators (e.g., --option=<hint>).
    • Required arguments now explicitly marked with "(Required)" labels.
    • Default values displayed in option descriptions for improved usability.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@cc75125). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #198   +/-   ##
=======================================
  Coverage        ?   97.24%           
=======================================
  Files           ?        8           
  Lines           ?      363           
  Branches        ?      125           
=======================================
  Hits            ?      353           
  Misses          ?        9           
  Partials        ?        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kricsleo kricsleo marked this pull request as ready for review April 9, 2025 05:40
Adapt improved usage tips (renderValueHint, renderDescription) to main's
color module and import style changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 15, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 30a4898f-cc89-4205-9596-0d851c14a340

📥 Commits

Reviewing files that changed from the base of the PR and between cc75125 and d8f7256.

📒 Files selected for processing (2)
  • src/usage.ts
  • test/usage.test.ts

📝 Walkthrough

Walkthrough

Refactored the usage message rendering logic in src/usage.ts by extracting inline formatting into dedicated helper functions (renderValueHint and renderDescription). Updated test snapshots reflect improved argument placeholders with explicit value indicators (e.g., --foo=<foo>) and annotations for required/default values.

Changes

Cohort / File(s) Summary
Usage Rendering Refactor
src/usage.ts
Introduced renderValueHint(arg) and renderDescription(arg, required) helper functions to replace inline formatting logic. Added snakeCase conversion for fallback value hints. Simplified boolean argument handling with composite description arrays.
Test Snapshots
test/usage.test.ts
Updated inline snapshots across multiple test cases to reflect new argument formatting: option placeholders now use equals syntax (e.g., --foo=<foo>), required arguments display explicit "(Required)" indicators, and default values are appended to descriptions (e.g., (Default: true)).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

A rabbit refactors with care,
Value hints floating in air,
From messy strings to functions clean,
Required flags now clearly seen,
The usage blooms—a helpful sight! 🐰✨

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

@pi0 pi0 merged commit ea428c7 into unjs:main Mar 15, 2026
4 checks passed
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.

Improve arg help usage message (placeholder)

2 participants