Skip to content

Improve CLI argument handling for task runner with trailing_var_arg#290

Merged
branchseer merged 2 commits intomainfrom
claude/fix-issue-285-clap-66odE
Mar 24, 2026
Merged

Improve CLI argument handling for task runner with trailing_var_arg#290
branchseer merged 2 commits intomainfrom
claude/fix-issue-285-clap-66odE

Conversation

@branchseer
Copy link
Member

Summary

This PR improves the command-line argument handling for the vp run command by properly configuring clap's trailing_var_arg feature at the command level and enhancing documentation around argument parsing behavior.

Key Changes

  • Moved trailing_var_arg to command level: Moved the trailing_var_arg = true attribute from the individual task_and_args field to the RunCommand struct itself, which is the correct way to configure this behavior in clap
  • Enhanced documentation: Added comprehensive comments explaining that flags intended for vp itself must appear before the task name, while all tokens after the task name are passed through verbatim to the task
  • Improved field naming and help text: Updated the task_and_args field with clearer value names (TASK_SPECIFIER and ADDITIONAL_ARGS) and a more descriptive long help message that explains the interactive task selector fallback
  • Refactored into_resolved method: Improved code clarity by explicitly binding intermediate values before constructing the ResolvedRunCommand
  • Updated test snapshots: Adjusted expected CLI usage output to reflect the new value names

Implementation Details

The change ensures that clap stops matching flags once the trailing positional argument (task name) starts being filled. This prevents flags like -v from being intercepted when they're intended for the task process. Flags for vp itself (e.g., --verbose, -r) must now appear before the task name.

Relates to: #285

https://claude.ai/code/session_018viAL2UGVNfLuUjTsi44HQ

claude added 2 commits March 23, 2026 16:14
Use `value_names = ["TASK_SPECIFIER", "ADDITIONAL_ARGS"]` so the help
output shows `[TASK_SPECIFIER] [ADDITIONAL_ARGS]...` instead of the
generic `[TASK_AND_ARGS]...`.

https://claude.ai/code/session_018viAL2UGVNfLuUjTsi44HQ
Note that omitting the task specifier in an interactive terminal opens
an interactive task selector.

https://claude.ai/code/session_018viAL2UGVNfLuUjTsi44HQ
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the vp run CLI parsing to ensure that once the task name is provided, all remaining tokens are forwarded verbatim to the underlying task process (preventing clap from consuming task-intended flags like -v), and refreshes the related help/usage output.

Changes:

  • Configure clap trailing_var_arg at the RunCommand (command) level instead of on the positional field.
  • Improve argument/help metadata for the task + passthrough-args positional (value names + long help).
  • Update a plan snapshot to match the new generated usage text.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/vite_task/src/cli/mod.rs Moves trailing_var_arg to the command level and updates help/value names for passthrough args.
crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache and --no-cache conflict.snap Updates expected clap-generated usage output for the renamed positional value placeholders.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member Author

branchseer commented Mar 24, 2026

Merge activity

  • Mar 24, 4:29 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 24, 4:29 AM UTC: @branchseer merged this pull request with Graphite.

@branchseer branchseer merged commit 4b5ae3d into main Mar 24, 2026
13 checks passed
@branchseer branchseer deleted the claude/fix-issue-285-clap-66odE branch March 24, 2026 04:29
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.

3 participants