File tree Expand file tree Collapse file tree 1 file changed +40
-1
lines changed
Expand file tree Collapse file tree 1 file changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ static async Task<int> RunAsync(string[] args)
9191 }
9292
9393 // No arguments or only options (no subcommand, no paths) - auto-detect and run test projects
94- if ( args . Length == 0 || args . All ( a => a . StartsWith ( '-' ) ) )
94+ if ( args . Length == 0 || IsOnlyOptions ( args ) )
9595 {
9696 return await HandleAutoRunAsync ( args ) ;
9797 }
@@ -249,6 +249,45 @@ static List<string> FindTestProjects(string rootDir)
249249 return testProjects ;
250250}
251251
252+ static bool IsOnlyOptions ( string [ ] args )
253+ {
254+ // Check if all arguments are options (--flag) or option values (following an option that takes a value)
255+ var optionsWithValues = new HashSet < string > ( StringComparer . OrdinalIgnoreCase )
256+ {
257+ "-f" , "--filter" ,
258+ "-t" , "--timeout" ,
259+ "--hang-timeout" ,
260+ "-w" , "--workers" ,
261+ "--log" ,
262+ "--resume" ,
263+ "--tree-depth" ,
264+ "--port" ,
265+ "--root"
266+ } ;
267+
268+ for ( var i = 0 ; i < args . Length ; i ++ )
269+ {
270+ var arg = args [ i ] ;
271+
272+ // If it starts with -, it's an option
273+ if ( arg . StartsWith ( '-' ) )
274+ {
275+ // If this option takes a value, skip the next argument
276+ if ( optionsWithValues . Contains ( arg ) && i + 1 < args . Length )
277+ {
278+ i ++ ; // Skip the value
279+ }
280+ continue ;
281+ }
282+
283+ // This is a non-option argument that's not a value for a previous option
284+ // It could be a subcommand or a path
285+ return false ;
286+ }
287+
288+ return true ;
289+ }
290+
252291static bool HasOption ( string [ ] args , params string [ ] options )
253292{
254293 return args . Any ( arg => options . Any ( option => arg . Equals ( option , StringComparison . OrdinalIgnoreCase ) ) ) ;
You can’t perform that action at this time.
0 commit comments