@@ -33,15 +33,8 @@ private static Set<String> validateArgs(String cmdName, ImmutableList<Argument<?
33
33
for (int i = 0 ; i < argName .length (); i ++) {
34
34
final char c = argName .charAt (i );
35
35
36
- Assertions .assertNotEquals (
37
- Argument .SEPARATOR , c ,
38
- () -> getIllegalCharacterMessage (cmdName , argName , Argument .SEPARATOR )
39
- );
40
-
41
- Assertions .assertNotEquals (
42
- Argument .NAME_DELIM , c ,
43
- () -> getIllegalCharacterMessage (cmdName , argName , Argument .NAME_DELIM )
44
- );
36
+ assertLegal (cmdName , argName , Argument .SEPARATOR , c );
37
+ assertLegal (cmdName , argName , Argument .NAME_DELIM , c );
45
38
}
46
39
47
40
Assertions .assertTrue (
@@ -53,8 +46,11 @@ private static Set<String> validateArgs(String cmdName, ImmutableList<Argument<?
53
46
return argNames ;
54
47
}
55
48
56
- private static String getIllegalCharacterMessage (String cmdName , String argName , char illegal ) {
57
- return "Command '%s' arg '%s' name must not contain '%s'" .formatted (cmdName , argName , illegal );
49
+ private static void assertLegal (String cmdName , String argName , char illegal , char actual ) {
50
+ Assertions .assertNotEquals (
51
+ illegal , actual ,
52
+ () -> "Command '%s' arg '%s' name must not contain '%s'" .formatted (cmdName , argName , illegal )
53
+ );
58
54
}
59
55
60
56
private static String getDuplicateNameMessage (String cmdName , String argName ) {
0 commit comments