diff --git a/console/src/main/java/org/jline/console/Printer.java b/console/src/main/java/org/jline/console/Printer.java index 22528f27f..f03f42abd 100644 --- a/console/src/main/java/org/jline/console/Printer.java +++ b/console/src/main/java/org/jline/console/Printer.java @@ -33,8 +33,8 @@ enum TableRows {EVEN, ODD, ALL} String ALL = "all"; /** * Value: {@code List}
- * Applies: TABLE
- * Display given columns on table. + * Applies: MAP and TABLE
+ * Display given keys/columns on map/table. */ String COLUMNS = "columns"; /** diff --git a/console/src/main/java/org/jline/console/impl/DefaultPrinter.java b/console/src/main/java/org/jline/console/impl/DefaultPrinter.java index 3f43a691b..f88c1732f 100644 --- a/console/src/main/java/org/jline/console/impl/DefaultPrinter.java +++ b/console/src/main/java/org/jline/console/impl/DefaultPrinter.java @@ -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", @@ -1060,6 +1060,10 @@ private void highlightMap(Map options int indent = (int)options.get(Printer.INDENTION); int maxDepth = (int)options.get(Printer.MAX_DEPTH); for (Map.Entry entry : map.entrySet()) { + if (depth == 0 && options.containsKey(Printer.COLUMNS) + && !((List)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");