File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed
Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @bomb.sh/tab ' : patch
3+ ---
4+
5+ fix: citty should not throw an error when there is no subcommand
Original file line number Diff line number Diff line change @@ -127,9 +127,6 @@ export default async function tab<TArgs extends ArgsDef>(
127127 }
128128
129129 const subCommands = await resolve ( instance . subCommands ) ;
130- if ( ! subCommands ) {
131- throw new Error ( 'Invalid or missing subCommands.' ) ;
132- }
133130
134131 const isPositional = isConfigPositional ( instance ) ;
135132
@@ -149,11 +146,13 @@ export default async function tab<TArgs extends ArgsDef>(
149146 }
150147 }
151148
152- await handleSubCommands (
153- subCommands ,
154- undefined ,
155- completionConfig ?. subCommands
156- ) ;
149+ if ( subCommands ) {
150+ await handleSubCommands (
151+ subCommands ,
152+ undefined ,
153+ completionConfig ?. subCommands
154+ ) ;
155+ }
157156
158157 if ( instance . args ) {
159158 for ( const [ argName , argConfig ] of Object . entries ( instance . args ) ) {
@@ -243,7 +242,11 @@ export default async function tab<TArgs extends ArgsDef>(
243242 } ,
244243 } ) ;
245244
246- subCommands . complete = completeCommand ;
245+ if ( ! subCommands ) {
246+ instance . subCommands = { complete : completeCommand } ;
247+ } else {
248+ subCommands . complete = completeCommand ;
249+ }
247250
248251 return t ;
249252}
You can’t perform that action at this time.
0 commit comments