1
1
/*
2
- * Copyright 2022 the original author or authors.
2
+ * Copyright 2022-2023 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -32,6 +32,14 @@ public interface CommandOption {
32
32
*/
33
33
String [] getLongNames ();
34
34
35
+ /**
36
+ * Gets a modified long names of an option. Set within a command registration if
37
+ * option name modifier were used to have an info about original names.
38
+ *
39
+ * @return modified long names of an option
40
+ */
41
+ String [] getLongNamesModified ();
42
+
35
43
/**
36
44
* Gets a short names of an option.
37
45
*
@@ -111,7 +119,7 @@ public interface CommandOption {
111
119
* @return default command option
112
120
*/
113
121
public static CommandOption of (String [] longNames , Character [] shortNames , String description ) {
114
- return of (longNames , shortNames , description , null , false , null , null , null , null , null , null );
122
+ return of (longNames , null , shortNames , description , null , false , null , null , null , null , null , null );
115
123
}
116
124
117
125
/**
@@ -125,13 +133,14 @@ public static CommandOption of(String[] longNames, Character[] shortNames, Strin
125
133
*/
126
134
public static CommandOption of (String [] longNames , Character [] shortNames , String description ,
127
135
ResolvableType type ) {
128
- return of (longNames , shortNames , description , type , false , null , null , null , null , null , null );
136
+ return of (longNames , null , shortNames , description , type , false , null , null , null , null , null , null );
129
137
}
130
138
131
139
/**
132
140
* Gets an instance of a default {@link CommandOption}.
133
141
*
134
142
* @param longNames the long names
143
+ * @param longNamesModified the modified long names
135
144
* @param shortNames the short names
136
145
* @param description the description
137
146
* @param type the type
@@ -144,10 +153,10 @@ public static CommandOption of(String[] longNames, Character[] shortNames, Strin
144
153
* @param completion the completion
145
154
* @return default command option
146
155
*/
147
- public static CommandOption of (String [] longNames , Character [] shortNames , String description ,
156
+ public static CommandOption of (String [] longNames , String [] longNamesModified , Character [] shortNames , String description ,
148
157
ResolvableType type , boolean required , String defaultValue , Integer position , Integer arityMin ,
149
158
Integer arityMax , String label , CompletionResolver completion ) {
150
- return new DefaultCommandOption (longNames , shortNames , description , type , required , defaultValue , position ,
159
+ return new DefaultCommandOption (longNames , longNamesModified , shortNames , description , type , required , defaultValue , position ,
151
160
arityMin , arityMax , label , completion );
152
161
}
153
162
@@ -157,6 +166,7 @@ public static CommandOption of(String[] longNames, Character[] shortNames, Strin
157
166
public static class DefaultCommandOption implements CommandOption {
158
167
159
168
private String [] longNames ;
169
+ private String [] longNamesModified ;
160
170
private Character [] shortNames ;
161
171
private String description ;
162
172
private ResolvableType type ;
@@ -168,11 +178,12 @@ public static class DefaultCommandOption implements CommandOption {
168
178
private String label ;
169
179
private CompletionResolver completion ;
170
180
171
- public DefaultCommandOption (String [] longNames , Character [] shortNames , String description ,
181
+ public DefaultCommandOption (String [] longNames , String [] longNamesModified , Character [] shortNames , String description ,
172
182
ResolvableType type , boolean required , String defaultValue , Integer position ,
173
183
Integer arityMin , Integer arityMax , String label ,
174
184
CompletionResolver completion ) {
175
185
this .longNames = longNames != null ? longNames : new String [0 ];
186
+ this .longNamesModified = longNamesModified != null ? longNamesModified : new String [0 ];
176
187
this .shortNames = shortNames != null ? shortNames : new Character [0 ];
177
188
this .description = description ;
178
189
this .type = type ;
@@ -190,6 +201,11 @@ public String[] getLongNames() {
190
201
return longNames ;
191
202
}
192
203
204
+ @ Override
205
+ public String [] getLongNamesModified () {
206
+ return longNamesModified ;
207
+ }
208
+
193
209
@ Override
194
210
public Character [] getShortNames () {
195
211
return shortNames ;
0 commit comments