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 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..b45a03e 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; @@ -71,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 -> c.getDiff() == LineChange.DiffEnum.DO_NOTHING) + .filter(c -> verbose && !isModifyingChange(c)) .doOnNext(change -> consoleHelper.writeLine(lineChangeFormatter.format(change), getChangeColor(change))), Mono.fromRunnable(consoleHelper::newLine) ))