Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/main/java/picocli/CommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -7938,9 +7938,11 @@ public void run() {
reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String txt = "";
String line;
StringBuilder txtBuf = new StringBuilder();
while ((line = reader.readLine()) != null) {
txt += " " + line;
txtBuf.append(" ").append(line);
}
txt = txtBuf.toString();
tracer.debug("getTerminalWidth() parsing output: %s", txt);
Pattern pattern = (Help.Ansi.isWindows() && !Help.Ansi.isPseudoTTY())
? Pattern.compile(".*?:\\s*(\\d+)\\D.*?:\\s*(\\d+)\\D.*", Pattern.DOTALL)
Expand Down Expand Up @@ -13111,17 +13113,18 @@ private boolean containsRequiredSubgroups(ArgGroupSpec argGroupSpec) {

private void failGroupMultiplicityExceeded(List<ParseResult.GroupMatch> groupMatches, CommandLine commandLine) {
Map<ArgGroupSpec, List<List<ParseResult.GroupMatch>>> matchesPerGroup = new LinkedHashMap<ArgGroupSpec, List<List<GroupMatch>>>();
String msg = "";
StringBuilder msgBuf = new StringBuilder();
for (ParseResult.GroupMatch match : groupMatches) {
if (msg.length() > 0) { msg += " and "; }
msg += match;
if (msgBuf.length() > 0) { msgBuf.append(" and "); }
msgBuf.append(match);
Map<ArgGroupSpec, GroupMatchContainer> subgroups = match.matchedSubgroups();
for (ArgGroupSpec group : subgroups.keySet()) {
if (group.validate()) { // don't raise errors for non-validating groups: https://github.com/remkop/picocli/issues/810
addValueToListInMap(matchesPerGroup, group, subgroups.get(group).matches());
}
}
}
String msg = msgBuf.toString();
if (!matchesPerGroup.isEmpty()) {
if (!simplifyErrorMessageForSingleGroup(matchesPerGroup, commandLine)) {
commandLine.interpreter.maybeThrow(new MaxValuesExceededException(commandLine, "Error: expected only one match but got " + msg));
Expand Down Expand Up @@ -15048,18 +15051,20 @@ private static String createMissingParameterMessage(ArgSpec argSpec, Range arity
return "Missing required parameter for " + optionDescription("", argSpec, 0);
}
String sep = "";
String names = ": ";
String indices = "";
StringBuilder namesBuf = new StringBuilder();
StringBuilder indicesBuf = new StringBuilder();
String infix = " at index ";
int count = 0;
for (PositionalParamSpec missing : missingList) {
if (missing.arity().min > 0) {
names += sep + "'" + missing.paramLabel() + "'";
indices += sep + missing.index();
namesBuf.append(sep).append("'").append(missing.paramLabel()).append("'");
indicesBuf.append(sep).append(missing.index());
sep = ", ";
count++;
}
}
String names = namesBuf.toString();
String indices = indicesBuf.toString();
String msg = "Missing required parameter";
if (count > 1 || arity.min - available > 1) {
msg += "s";
Expand Down
Loading