Skip to content

Commit

Permalink
DefaultPrinter: map print enable option for keys selection
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Apr 9, 2021
1 parent 92a63e1 commit 169f9cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions console/src/main/java/org/jline/console/Printer.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ enum TableRows {EVEN, ODD, ALL}
String ALL = "all";
/**
* Value: {@code List<String>}<br>
* Applies: TABLE<br>
* Display given columns on table.
* Applies: MAP and TABLE<br>
* Display given keys/columns on map/table.
*/
String COLUMNS = "columns";
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public String[] appendUsage(String[] customUsage) {
" -? --help Displays command help",
" -a --all Ignore columnsOut configuration",
" -b --border=CHAR Table cell vertical border character",
" -c --columns=COLUMNS,... Display given columns on table",
" -c --columns=COLUMNS,... Display given columns on map/table",
" -e --exclude=COLUMNS,... Exclude given columns on table",
" -i --include=COLUMNS,... Include given columns on table",
" --indention=INDENTION Indention size",
Expand Down Expand Up @@ -1060,6 +1060,10 @@ private void highlightMap(Map<String, Object> options
int indent = (int)options.get(Printer.INDENTION);
int maxDepth = (int)options.get(Printer.MAX_DEPTH);
for (Map.Entry<String, Object> entry : map.entrySet()) {
if (depth == 0 && options.containsKey(Printer.COLUMNS)
&& !((List<String>)options.get(Printer.COLUMNS)).contains(entry.getKey())) {
continue;
}
AttributedStringBuilder asb = new AttributedStringBuilder().tabs(Arrays.asList(0, depth*indent, depth*indent + max + 1));
if (depth != 0) {
asb.append("\t");
Expand Down

0 comments on commit 169f9cf

Please sign in to comment.