File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
src/Cli/dotnet/Extensions Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,16 @@ public static bool IsTopLevelDotnetCommand(this ParseResult parseResult)
107107 return parseResult . CommandResult . Command . Equals ( Parser . RootCommand ) && string . IsNullOrEmpty ( parseResult . RootSubCommandResult ( ) ) ;
108108 }
109109
110- public static bool CanBeInvoked ( this ParseResult parseResult ) => parseResult . Action is not null ;
110+ public static bool CanBeInvoked ( this ParseResult parseResult ) =>
111+ parseResult . Action is not null // we have an invokable action (meaning .SetAction was called)
112+ && IsNotRootCommandWithUnknownArg ( parseResult ) ;
113+
114+ public static bool IsNotRootCommandWithUnknownArg ( this ParseResult parseResult ) =>
115+ parseResult . CommandResult is { Command : var chosenCommand } // we have a command
116+ && (
117+ chosenCommand != Parser . RootCommand // not the root command, or
118+ // is the root command but isn't an unbound subcommand
119+ || ( chosenCommand == Parser . RootCommand && parseResult . GetValue < string > ( Parser . DotnetSubCommand ) is null ) ) ;
111120
112121 public static int HandleMissingCommand ( this ParseResult parseResult )
113122 {
You can’t perform that action at this time.
0 commit comments