From 26f584e05a3c98c2b68a2ba71c39df8bc93e4f26 Mon Sep 17 00:00:00 2001 From: Chuckame Date: Sat, 21 Nov 2020 16:03:09 +0100 Subject: [PATCH 1/3] Added verbose mode --- .../chuckame/marlinfw/configurator/command/ApplyCommand.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/chuckame/marlinfw/configurator/command/ApplyCommand.java b/src/main/java/fr/chuckame/marlinfw/configurator/command/ApplyCommand.java index f0bf967..14d633f 100644 --- a/src/main/java/fr/chuckame/marlinfw/configurator/command/ApplyCommand.java +++ b/src/main/java/fr/chuckame/marlinfw/configurator/command/ApplyCommand.java @@ -36,6 +36,8 @@ public class ApplyCommand implements Command { private boolean doSave; @Parameter(names = {"--yes", "-y"}, description = "when present, the changes will be saved without prompting the user") private boolean applyWithoutPrompt; + @Parameter(names = {"--verbose", "-v"}, description = "when present, all non-changed line are printed") + private boolean verbose; private final ProfileAdapter profileAdapter; private final LineChangeManager lineChangeManager; @@ -81,7 +83,7 @@ private Mono printChanges(final Map> changes) { .doOnNext(change -> consoleHelper.writeLine(lineChangeFormatter.format(change), getChangeColor(change))), Flux.fromIterable(fileChanges.getValue()) .filter(LineChange::isConstant) - .filter(c -> c.getDiff() == LineChange.DiffEnum.DO_NOTHING) + .filter(c -> verbose && c.getDiff() == LineChange.DiffEnum.DO_NOTHING) .doOnNext(change -> consoleHelper.writeLine(lineChangeFormatter.format(change), getChangeColor(change))), Mono.fromRunnable(consoleHelper::newLine) )) From a76ae2e9bf29ca1f8144d903258276bb208e8212 Mon Sep 17 00:00:00 2001 From: Chuckame Date: Wed, 16 Dec 2020 11:13:12 +0100 Subject: [PATCH 2/3] Update readme with the new param --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 7f08dd9..5a58103 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,9 @@ Usage: marlin-console-configurator [command] [command options] --save, -s When is present, will save changes to files. Else, just display changes without saving Default: false + --verbose, -v + when present, all non-changed line are printed + Default: false --yes, -y when present, the changes will be saved without prompting the user Default: false From 6c6205b6769c65d8c76f8c8090950e269d2babe1 Mon Sep 17 00:00:00 2001 From: Chuckame Date: Wed, 16 Dec 2020 11:51:15 +0100 Subject: [PATCH 3/3] Write to console "XX change(s) to apply for file XX" only when verbose or at least one change --- .../configurator/command/ApplyCommand.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/fr/chuckame/marlinfw/configurator/command/ApplyCommand.java b/src/main/java/fr/chuckame/marlinfw/configurator/command/ApplyCommand.java index 14d633f..b45a03e 100644 --- a/src/main/java/fr/chuckame/marlinfw/configurator/command/ApplyCommand.java +++ b/src/main/java/fr/chuckame/marlinfw/configurator/command/ApplyCommand.java @@ -73,17 +73,19 @@ private Mono>> prepareChanges(final Map printChanges(final Map> changes) { return Flux.fromIterable(changes.entrySet()) .concatMap(fileChanges -> Flux.concat( - Mono.fromRunnable(() -> consoleHelper - .writeLine(String.format("%s change(s) to apply for file %s:", fileChanges.getValue().stream().filter(this::isModifyingChange) - .count(), fileChanges - .getKey()), ConsoleHelper.FormatterEnum.UNDERLINED, ConsoleHelper.FormatterEnum.BOLD, ConsoleHelper.ForegroundColorEnum.GREEN)), + Flux.fromIterable(fileChanges.getValue()) + .filter(this::isModifyingChange) + .count() + .filter(count -> verbose || count > 0) + .doOnNext(count -> consoleHelper.writeLine(String.format("%s change(s) to apply for file %s:", count, fileChanges + .getKey()), ConsoleHelper.FormatterEnum.UNDERLINED, ConsoleHelper.FormatterEnum.BOLD, ConsoleHelper.ForegroundColorEnum.GREEN)), Flux.fromIterable(fileChanges.getValue()) .filter(LineChange::isConstant) - .filter(c -> c.getDiff() != LineChange.DiffEnum.DO_NOTHING) + .filter(this::isModifyingChange) .doOnNext(change -> consoleHelper.writeLine(lineChangeFormatter.format(change), getChangeColor(change))), Flux.fromIterable(fileChanges.getValue()) .filter(LineChange::isConstant) - .filter(c -> verbose && c.getDiff() == LineChange.DiffEnum.DO_NOTHING) + .filter(c -> verbose && !isModifyingChange(c)) .doOnNext(change -> consoleHelper.writeLine(lineChangeFormatter.format(change), getChangeColor(change))), Mono.fromRunnable(consoleHelper::newLine) ))