10
10
import java .util .List ;
11
11
import java .util .Map ;
12
12
import java .util .Optional ;
13
+ import java .util .Set ;
13
14
import java .util .concurrent .Callable ;
14
15
import java .util .function .Supplier ;
15
16
import java .util .stream .Collectors ;
@@ -66,6 +67,8 @@ public class QuarkusCli implements QuarkusApplication, Callable<Integer> {
66
67
System .setProperty ("picocli.endofoptions.description" , "End of command line options." );
67
68
}
68
69
70
+ private static final Set <String > CATCH_ALL_COMMANDS = Set .of ("create" , "image" , "extension" , "ext" , "plugin" , "plug" );
71
+
69
72
@ Inject
70
73
CommandLine .IFactory factory ;
71
74
@@ -125,7 +128,7 @@ public int run(String... args) throws Exception {
125
128
pluginCommandFactory .populateCommands (cmd , plugins );
126
129
missingCommand .filter (m -> !plugins .containsKey (m )).ifPresent (m -> {
127
130
try {
128
- output .info ("Command %s is not available , looking for available plugins ..." , m );
131
+ output .info ("Unable to match command `%s` , looking for available plugins..." , m );
129
132
Map <String , Plugin > installable = pluginManager .getInstallablePlugins ();
130
133
if (installable .containsKey (m )) {
131
134
Plugin candidate = installable .get (m );
@@ -140,10 +143,10 @@ public int run(String... args) throws Exception {
140
143
pluginCommandFactory .populateCommands (cmd , plugins );
141
144
}
142
145
} else {
143
- output .error ("Command %s is missing and can 't be installed." , m );
146
+ output .error ("Unable to match command `%s` and a corresponding plugin couldn 't be installed." , m );
144
147
}
145
148
} catch (Exception e ) {
146
- output .error ("Command %s is missing and can 't be installed." , m );
149
+ output .error ("Unable to match command `%s` and a corresponding plugin couldn 't be installed." , m );
147
150
}
148
151
});
149
152
} catch (MutuallyExclusiveArgsException e ) {
@@ -166,6 +169,12 @@ public Optional<String> checkMissingCommand(CommandLine root, String[] args) {
166
169
167
170
try {
168
171
ParseResult currentParseResult = root .parseArgs (args );
172
+
173
+ // some commands are catch all and they will match always
174
+ if (CATCH_ALL_COMMANDS .contains (currentParseResult .commandSpec ().name ())) {
175
+ return Optional .empty ();
176
+ }
177
+
169
178
StringBuilder missingCommand = new StringBuilder ();
170
179
171
180
do {
@@ -188,6 +197,11 @@ public Optional<String> checkMissingCommand(CommandLine root, String[] args) {
188
197
189
198
return Optional .empty ();
190
199
} catch (UnmatchedArgumentException e ) {
200
+ // the first element was matched so it's not missing
201
+ if (e .getCommandLine () != root ) {
202
+ return Optional .empty ();
203
+ }
204
+
191
205
return Optional .of (args [0 ]);
192
206
} catch (Exception e ) {
193
207
// For any other exceptions (e.g. MissingParameterException), we should just ignore.
0 commit comments