You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: positional argument completion broken after flags (#111)
* fix: positional argument completion broken after flags
Three interacting bugs prevented positional argument completion when
flags preceded the argument (e.g., 'mycli logs -f <TAB>'):
1. handlePositionalCompletion received raw args including flags, so its
positional index calculation was inflated. Fix: call stripOptions()
on previousArgs before counting positions.
2. parse() had an early return after detecting a boolean flag that
skipped both handleCommandCompletion and handlePositionalCompletion.
Fix: remove the early return to let control fall through.
3. The commander adapter marked ALL options as isBoolean=true, even
value-taking ones like '--output <format>'. This caused stripOptions
to not skip the value argument, further corrupting the positional
index. Fix: detect '<' or '[' in flag syntax and register with a
no-op handler to force isBoolean=false.
Fixes#110
* style: revert cosmetic linter changes, keep only meaningful fix
Remove import reordering, trailing comma additions, arrow function
conversion, and test.each reformatting that were introduced by a
linter not used by the project. Retains only the actual bug fix
for positional completion after flags.
* pnpm changeset
---------
Co-authored-by: AmirSa12 <amirhosseinpr184@gmail.com>
Copy file name to clipboardExpand all lines: tests/__snapshots__/cli.test.ts.snap
+14-19Lines changed: 14 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -506,12 +506,18 @@ exports[`cli completion tests for citty > root command argument tests > should c
506
506
"dev Start dev server
507
507
copy Copy files
508
508
lint Lint project
509
+
my-app My application
510
+
my-lib My library
511
+
my-tool My tool
509
512
:4
510
513
"
511
514
`;
512
515
513
516
exports[`cli completion tests for citty > root command argument tests > should complete root command project argument with options and partial input 1`] =`
514
-
":4
517
+
"my-app My application
518
+
my-lib My library
519
+
my-tool My tool
520
+
:4
515
521
"
516
522
`;
517
523
@@ -620,23 +626,6 @@ my-tool My tool
620
626
"
621
627
`;
622
628
623
-
exports[`cli completion tests for commander > cli option value handling > should handle unknown options with no completions 1`] =`":4"`;
624
-
625
-
exports[`cli completion tests for commander > short flag handling > should handle global short flags 1`] =`
626
-
"-c specify config file
627
-
:4
628
-
"
629
-
`;
630
-
631
-
exports[`cli completion tests for commander > should complete cli options 1`] =`
632
-
"serve Start the server
633
-
build Build the project
634
-
deploy Deploy the application
635
-
lint Lint source files
636
-
:4
637
-
"
638
-
`;
639
-
640
629
exports[`cli completion tests for t > --config option tests > should complete --config option values 1`] =`
641
630
"vite.config.ts Vite config file
642
631
vite.config.js Vite config file
@@ -846,12 +835,18 @@ exports[`cli completion tests for t > root command argument tests > should compl
846
835
serve Start the server
847
836
copy Copy files
848
837
lint Lint project
838
+
my-app My application
839
+
my-lib My library
840
+
my-tool My tool
849
841
:4
850
842
"
851
843
`;
852
844
853
845
exports[`cli completion tests for t > root command argument tests > should complete root command project argument with options and partial input 1`] =`
0 commit comments