Skip to content

fix: resolve CLI command arg parsing for tags, payment, import and improve error handling - #15

Merged
nazozokc merged 2 commits into
mainfrom
AI-agent
Jun 18, 2026
Merged

nazozokc merged 2 commits into
mainfrom
AI-agent

Conversation

@nazozokc

@nazozokc nazozokc commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Summary

バグチェックで見つかった以下の問題を修正:

Bug fixes

  1. tags command: ctx.positionals にコマンド名が含まれる問題を修正。位置引数 names を定義し ctx.values.names を使うように変更。また引数なしでの実行時にエラーメッセージを表示するようにした。

  2. payment command: period 位置引数が必須になっていた問題を修正。required: false を追加し、省略時はデフォルトで monthly になるようにした。

  3. import --dry-run: --dry-run フラグが認識されない問題を修正。toKebab: true を追加し、dryRun プロパティが --dry-run として使えるようにした。

  4. Version mismatch: src/index.ts のバージョンが 2.2.0 と古かったので 3.0.1 に統一。

  5. Error handling: 必須引数欠落時の AggregateError をキャッチし、スタックトレースではなくユーザーフレンドリーなエラーメッセージを表示するようにした。ついでに ExitPromptError(Ctrl+C)のハンドリングも追加。

Verification

  • ✅ 全142既存テスト通過
  • pnpm build 成功
  • ✅ 各修正コマンドの動作確認済み

Summary by CodeRabbit

  • New Features

    • Payment command's period argument is now optional, defaulting to "monthly" when omitted.
  • Bug Fixes

    • Improved error handling with clearer error messages and proper exit codes.
    • Tags command now validates that at least one tag name is provided.
  • Chores

    • Version bumped to 3.0.1.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@nazozokc, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 56 minutes and 29 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 14360770-2ee4-4362-903e-06b38d070591

📥 Commits

Reviewing files that changed from the base of the PR and between 1c2d7ea and 6393a63.

📒 Files selected for processing (1)
  • subtrack/src/index.ts
📝 Walkthrough

Walkthrough

subtrack/src/index.ts is updated to fix argument parsing in the tags, import, and payment commands, and to replace the bare top-level await cli(...) call with a try/catch block that handles ExitPromptError, AggregateError, and unknown errors distinctly. The CLI version is bumped from 2.2.0 to 3.0.1.

Changes

CLI Command and Entrypoint Updates

Layer / File(s) Summary
Command argument parsing fixes
subtrack/src/index.ts
tags switches from ctx.positionals to a declared positional array argument names; import adds toKebab: true; payment's period positional is set to required: false with a "monthly" default.
CLI entrypoint error handling and version bump
subtrack/src/index.ts
Wraps cli(...) in a try/catch, exits with code 0 on ExitPromptError, logs sub-errors and exits with code 1 on AggregateError, rethrows all other errors, bumps version to 3.0.1, and explicitly specifies subCommands inside the call.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • nazozokc/subtrack#13: Introduced the Gunshi-based CLI migration and the initial tags/import/payment command definitions in subtrack/src/index.ts that this PR directly builds on.

Poem

🐇 Hop, hop, the CLI grows bright,
Tags now named, kebab'd just right,
Period optional? Monthly by default!
Errors caught with a gentle halt—
AggregateError logs each tale,
ExitPromptError won't derail.
Version 3.0.1, what a trail! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: CLI command argument parsing fixes for multiple commands and error handling improvements, matching the primary objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch AI-agent

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@subtrack/src/index.ts`:
- Around line 76-78: The code block checking if tagNames.length === 0 logs an
error message with consola.error but returns without setting an exit code,
causing the CLI process to exit with code 0 (success) despite the error. To fix
this, add process.exitCode = 1 before the return statement in the
tagNames.length === 0 condition block to properly signal a failed execution to
CLI automation tools.
- Around line 74-80: The `handleTags(tagNames)` call in the `run` method is not
being awaited or returned, which causes any errors thrown by the async
`handleTags` function to escape the try/catch block and surface as unhandled
rejections. Fix this by either returning the promise directly with `return
handleTags(tagNames)` or awaiting it with `await handleTags(tagNames)` to ensure
errors are properly caught and handled.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a2085a99-1ce6-44b3-a9bd-3327704f02de

📥 Commits

Reviewing files that changed from the base of the PR and between c806cc9 and 1c2d7ea.

📒 Files selected for processing (1)
  • subtrack/src/index.ts

Comment thread subtrack/src/index.ts
Comment on lines 74 to +80
run: (ctx) => {
if (ctx.positionals.length === 0) {
const tagNames = (ctx.values.names ?? []) as string[]
if (tagNames.length === 0) {
consola.error("Please specify at least one tag")
return
}
handleTags(ctx.positionals)
handleTags(tagNames)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Return the async tags handler so errors propagate correctly.

On Line 80, handleTags(tagNames) is called but not returned/awaited. Since handleTags is async (subtrack/src/commands.ts, Line 182), this can escape the try/catch at Lines 183-213 and surface as an unhandled rejection.

Suggested fix
-  run: (ctx) => {
+  run: (ctx) => {
     const tagNames = (ctx.values.names ?? []) as string[]
     if (tagNames.length === 0) {
       consola.error("Please specify at least one tag")
       return
     }
-    handleTags(tagNames)
+    return handleTags(tagNames)
   },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run: (ctx) => {
if (ctx.positionals.length === 0) {
const tagNames = (ctx.values.names ?? []) as string[]
if (tagNames.length === 0) {
consola.error("Please specify at least one tag")
return
}
handleTags(ctx.positionals)
handleTags(tagNames)
run: (ctx) => {
const tagNames = (ctx.values.names ?? []) as string[]
if (tagNames.length === 0) {
consola.error("Please specify at least one tag")
return
}
return handleTags(tagNames)
},
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@subtrack/src/index.ts` around lines 74 - 80, The `handleTags(tagNames)` call
in the `run` method is not being awaited or returned, which causes any errors
thrown by the async `handleTags` function to escape the try/catch block and
surface as unhandled rejections. Fix this by either returning the promise
directly with `return handleTags(tagNames)` or awaiting it with `await
handleTags(tagNames)` to ensure errors are properly caught and handled.

Comment thread subtrack/src/index.ts
Comment on lines +76 to 78
if (tagNames.length === 0) {
consola.error("Please specify at least one tag")
return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Set a non-zero exit code for invalid tags invocation.

On Lines 76-78, missing required user input logs an error but returns success. CLI automation will treat this as a successful run. Set process.exitCode = 1 before returning.

Suggested fix
     if (tagNames.length === 0) {
       consola.error("Please specify at least one tag")
+      process.exitCode = 1
       return
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (tagNames.length === 0) {
consola.error("Please specify at least one tag")
return
if (tagNames.length === 0) {
consola.error("Please specify at least one tag")
process.exitCode = 1
return
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@subtrack/src/index.ts` around lines 76 - 78, The code block checking if
tagNames.length === 0 logs an error message with consola.error but returns
without setting an exit code, causing the CLI process to exit with code 0
(success) despite the error. To fix this, add process.exitCode = 1 before the
return statement in the tagNames.length === 0 condition block to properly signal
a failed execution to CLI automation tools.

@nazozokc
nazozokc merged commit e06501d into main Jun 18, 2026
10 checks passed
@nazozokc
nazozokc deleted the AI-agent branch June 18, 2026 13:49
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.

1 participant