Skip to content

Commit 169f9cf

Browse files
committed
DefaultPrinter: map print enable option for keys selection
1 parent 92a63e1 commit 169f9cf

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

console/src/main/java/org/jline/console/Printer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ enum TableRows {EVEN, ODD, ALL}
3333
String ALL = "all";
3434
/**
3535
* Value: {@code List<String>}<br>
36-
* Applies: TABLE<br>
37-
* Display given columns on table.
36+
* Applies: MAP and TABLE<br>
37+
* Display given keys/columns on map/table.
3838
*/
3939
String COLUMNS = "columns";
4040
/**

console/src/main/java/org/jline/console/impl/DefaultPrinter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public String[] appendUsage(String[] customUsage) {
8686
" -? --help Displays command help",
8787
" -a --all Ignore columnsOut configuration",
8888
" -b --border=CHAR Table cell vertical border character",
89-
" -c --columns=COLUMNS,... Display given columns on table",
89+
" -c --columns=COLUMNS,... Display given columns on map/table",
9090
" -e --exclude=COLUMNS,... Exclude given columns on table",
9191
" -i --include=COLUMNS,... Include given columns on table",
9292
" --indention=INDENTION Indention size",
@@ -1060,6 +1060,10 @@ private void highlightMap(Map<String, Object> options
10601060
int indent = (int)options.get(Printer.INDENTION);
10611061
int maxDepth = (int)options.get(Printer.MAX_DEPTH);
10621062
for (Map.Entry<String, Object> entry : map.entrySet()) {
1063+
if (depth == 0 && options.containsKey(Printer.COLUMNS)
1064+
&& !((List<String>)options.get(Printer.COLUMNS)).contains(entry.getKey())) {
1065+
continue;
1066+
}
10631067
AttributedStringBuilder asb = new AttributedStringBuilder().tabs(Arrays.asList(0, depth*indent, depth*indent + max + 1));
10641068
if (depth != 0) {
10651069
asb.append("\t");

0 commit comments

Comments
 (0)