Commit 4b5ae3d
authored
Improve CLI argument handling for task runner with trailing_var_arg (#290)
## 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_018viAL2UGVNfLuUjTsi44HQ1 parent 62dbcab commit 4b5ae3d
File tree
2 files changed
+21
-11
lines changed- crates
- vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots
- vite_task/src/cli
2 files changed
+21
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
77 | 85 | | |
| 86 | + | |
78 | 87 | | |
79 | 88 | | |
80 | 89 | | |
| |||
83 | 92 | | |
84 | 93 | | |
85 | 94 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
91 | 100 | | |
92 | 101 | | |
93 | 102 | | |
| |||
160 | 169 | | |
161 | 170 | | |
162 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
163 | 175 | | |
164 | 176 | | |
165 | 177 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
171 | 181 | | |
172 | 182 | | |
173 | 183 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
0 commit comments