Skip to content

Commit

Permalink
prnt command: improve management of option --columns=<fields>
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Jun 4, 2021
1 parent 9739190 commit a1fcd9f
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions console/src/main/java/org/jline/console/impl/DefaultPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ private List<Object> objectToList(Object obj) {
return out;
}

private boolean similarSets(final Set<String> ref, final Set<String> c2, final int matchLimit) {
private boolean similarSets(final List<String> ref, final Set<String> c2, final int matchLimit) {
boolean out = false;
int limit = matchLimit;
for (String s : ref) {
Expand Down Expand Up @@ -785,28 +785,24 @@ private void highlightAndPrint(Map<String, Object> options, Object obj) {
List<String> header = new ArrayList<>();
List<Integer> columns = new ArrayList<>();
int headerWidth = 0;
Set<String> refKeys = new HashSet<>();
List<String> refKeys = new ArrayList<>();
for (String v : _header) {
String value = v.split("\\.")[0];
if (!keys.contains(value)) {
continue;
}
if (!options.containsKey(Printer.COLUMNS) &&
!options.containsKey(Printer.STRUCT_ON_TABLE)) {
boolean simple = true;
for (Map<String,Object> m : convertedCollection) {
if (m.containsKey(value)) {
Object val = mapValue(options, v, m);
if (!simpleObject(val)) {
simple = false;
}
break;
}
}
if (!simple) {
continue;
boolean addKey = false;
for (Map<String, Object> m : convertedCollection) {
Object val = mapValue(options, v, m);
if (val != null) {
addKey = simpleObject(val) || options.containsKey(Printer.COLUMNS)
|| options.containsKey(Printer.STRUCT_ON_TABLE);
break;
}
}
if (!addKey) {
continue;
}
refKeys.add(value);
header.add(v);
String cn = columnName(v, options.containsKey(Printer.SHORT_NAMES));
Expand Down

0 comments on commit a1fcd9f

Please sign in to comment.