diff --git a/src/main/java/dev/jbang/cli/Alias.java b/src/main/java/dev/jbang/cli/Alias.java index abd7e4e4d..4e179885a 100644 --- a/src/main/java/dev/jbang/cli/Alias.java +++ b/src/main/java/dev/jbang/cli/Alias.java @@ -172,6 +172,8 @@ class AliasList extends BaseAliasCommand { @CommandLine.Mixin FormatMixin formatMixin; + private static final int INDENT_SIZE = 3; + @Override public Integer doCall() { PrintStream out = System.out; @@ -233,7 +235,7 @@ static void printAliasesWithOrigin(PrintStream out, String catalogName, Catalog } else { catalogs.forEach(cat -> { out.println(ConsoleOutput.bold(cat.resourceRef)); - cat.aliases.forEach(a -> printAlias(out, a, 3)); + cat.aliases.forEach(a -> printAlias(out, a, 1)); }); } } @@ -280,32 +282,31 @@ private static AliasOut getAliasOut(String catalogName, Catalog catalog, String } private static void printAlias(PrintStream out, AliasOut alias, int indent) { - out.print(Util.repeat(" ", indent)); - String prefix = Util.repeat(" ", alias.fullName.length() + indent); + String prefix1 = Util.repeat(" ", indent * INDENT_SIZE); + String prefix2 = Util.repeat(" ", (indent + 1) * INDENT_SIZE); + String prefix3 = Util.repeat(" ", (indent + 2) * INDENT_SIZE); + out.println(prefix1 + ConsoleOutput.yellow(alias.fullName)); if (alias.description != null) { - out.println(ConsoleOutput.yellow(alias.fullName) + " = " + alias.description); - if (Util.isVerbose()) - out.println(prefix + ConsoleOutput.faint(" (" + alias.scriptRef + ")")); - } else { - out.println(ConsoleOutput.yellow(alias.fullName) + " = " + alias.scriptRef); + out.println(prefix2 + alias.description); } + out.println(prefix2 + ConsoleOutput.faint(alias.scriptRef)); if (alias.arguments != null) { - out.println(prefix + ConsoleOutput.cyan(" Arguments: ") + String.join(" ", alias.arguments)); + out.println(prefix3 + ConsoleOutput.cyan(" Arguments: ") + String.join(" ", alias.arguments)); } if (alias.javaVersion != null) { - out.println(prefix + ConsoleOutput.cyan(" Java Version: ") + alias.javaVersion); + out.println(prefix3 + ConsoleOutput.cyan(" Java Version: ") + alias.javaVersion); } if (alias.mainClass != null) { - out.println(prefix + ConsoleOutput.cyan(" Main Class: ") + alias.mainClass); + out.println(prefix3 + ConsoleOutput.cyan(" Main Class: ") + alias.mainClass); } if (alias.enablePreview != null) { - out.println(prefix + ConsoleOutput.cyan(" Enable Preview: ") + alias.enablePreview); + out.println(prefix3 + ConsoleOutput.cyan(" Enable Preview: ") + alias.enablePreview); } if (alias.javaOptions != null) { - out.println(prefix + ConsoleOutput.cyan(" Java Options: ") + String.join(" ", alias.javaOptions)); + out.println(prefix3 + ConsoleOutput.cyan(" Java Options: ") + String.join(" ", alias.javaOptions)); } if (alias.properties != null) { - out.println(prefix + ConsoleOutput.magenta(" Properties: ") + alias.properties); + out.println(prefix3 + ConsoleOutput.magenta(" Properties: ") + alias.properties); } } } diff --git a/src/main/java/dev/jbang/cli/Catalog.java b/src/main/java/dev/jbang/cli/Catalog.java index dda10b042..115ec1f93 100644 --- a/src/main/java/dev/jbang/cli/Catalog.java +++ b/src/main/java/dev/jbang/cli/Catalog.java @@ -132,6 +132,8 @@ class CatalogList extends BaseCatalogCommand { @CommandLine.Mixin FormatMixin formatMixin; + private static final int INDENT_SIZE = 3; + @Override public Integer doCall() { PrintStream out = System.out; @@ -237,7 +239,7 @@ static void printCatalogsWithOrigin(PrintStream out, String catalogName, dev.jba } else { catalogs.forEach(cat -> { out.println(ConsoleOutput.bold(cat.resourceRef)); - cat.catalogs.forEach(c -> printCatalogRef(out, c, 3)); + cat.catalogs.forEach(c -> printCatalogRef(out, c, 1)); }); } } @@ -297,14 +299,13 @@ private static CatalogRefOut getCatalogRefOut(String catalogName, dev.jbang.cata } private static void printCatalogRef(PrintStream out, CatalogRefOut catalogRef, int indent) { - out.print(Util.repeat(" ", indent)); + String prefix1 = Util.repeat(" ", indent * INDENT_SIZE); + String prefix2 = Util.repeat(" ", (indent + 1) * INDENT_SIZE); + out.println(prefix1 + ConsoleOutput.yellow(catalogRef.fullName)); if (catalogRef.description != null) { - out.println(ConsoleOutput.yellow(catalogRef.fullName) + " = " + catalogRef.description); - out.println(Util.repeat(" ", catalogRef.fullName.length() + indent) + " (" - + catalogRef.catalogRef + ")"); - } else { - out.println(ConsoleOutput.yellow(catalogRef.fullName) + " = " + catalogRef.catalogRef); + out.println(prefix2 + catalogRef.description); } + out.println(prefix2 + catalogRef.catalogRef); } } diff --git a/src/main/java/dev/jbang/cli/Template.java b/src/main/java/dev/jbang/cli/Template.java index 72c62465b..81d5094f7 100644 --- a/src/main/java/dev/jbang/cli/Template.java +++ b/src/main/java/dev/jbang/cli/Template.java @@ -287,6 +287,8 @@ class TemplateList extends BaseTemplateCommand { @CommandLine.Mixin FormatMixin formatMixin; + private static final int INDENT_SIZE = 3; + @Override public Integer doCall() { PrintStream out = System.out; @@ -351,7 +353,7 @@ static void printTemplatesWithOrigin(PrintStream out, String catalogName, Catalo } else { catalogs.forEach(cat -> { out.println(ConsoleOutput.bold(cat.resourceRef)); - cat.templates.forEach(t -> printTemplate(out, t, 3)); + cat.templates.forEach(t -> printTemplate(out, t, 1)); }); } } @@ -403,27 +405,29 @@ private static TemplateOut getTemplateOut(String catalogName, Catalog catalog, S } private static void printTemplate(PrintStream out, TemplateOut template, int indent) { + String prefix1 = Util.repeat(" ", indent * INDENT_SIZE); + String prefix2 = Util.repeat(" ", (indent + 1) * INDENT_SIZE); + String prefix3 = Util.repeat(" ", (indent + 2) * INDENT_SIZE); out.print(Util.repeat(" ", indent)); + out.println(prefix1 + ConsoleOutput.yellow(template.fullName)); if (template.description != null) { - out.println(ConsoleOutput.yellow(template.fullName) + " = " + template.description); - } else { - out.println(ConsoleOutput.yellow(template.fullName) + " = "); + out.println(prefix2 + template.description); } if (template.fileRefs != null) { + out.println(prefix2 + "Files:"); for (FileRefOut fro : template.fileRefs) { - out.print(Util.repeat(" ", indent)); if (fro.resolved.equals(fro.destination)) { - out.println(" " + fro.resolved); + out.println(prefix3 + fro.resolved); } else { - out.println(" " + fro.destination + " (from " + fro.resolved + ")"); + out.println(prefix3 + fro.destination + " (from " + fro.resolved + ")"); } } } if (template.properties != null) { + out.println(prefix2 + "Properties:"); for (Map.Entry entry : template.properties.entrySet()) { - out.print(Util.repeat(" ", indent)); StringBuilder propertyLineBuilder = new StringBuilder() - .append(Util.repeat(" ", indent + 4)) + .append(prefix3) .append(ConsoleOutput.cyan(entry.getKey())) .append(" = "); if (entry.getValue().getDescription() != null) {