From b1d1ae11d8ec627a92a3b428c8c215dbe9c4f903 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Tue, 28 Nov 2023 14:46:11 +0100 Subject: [PATCH] feat(compare-command): Make the context size configurable via an option Signed-off-by: Sebastian Schuberth --- .../commands/compare/src/main/kotlin/CompareCommand.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/commands/compare/src/main/kotlin/CompareCommand.kt b/plugins/commands/compare/src/main/kotlin/CompareCommand.kt index f1559ccd04329..ea4919ff60edd 100644 --- a/plugins/commands/compare/src/main/kotlin/CompareCommand.kt +++ b/plugins/commands/compare/src/main/kotlin/CompareCommand.kt @@ -34,6 +34,7 @@ import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.types.enum import com.github.ajalt.clikt.parameters.types.file +import com.github.ajalt.clikt.parameters.types.int import com.github.ajalt.mordant.rendering.Theme import com.github.difflib.DiffUtils import com.github.difflib.UnifiedDiffUtils @@ -70,6 +71,12 @@ class CompareCommand : OrtCommand( ).enum() .default(CompareMethod.TEXT_DIFF) + private val contextSize by option( + "--context-size", "-s", + help = "The context size to use for the unified diff." + ).int() + .default(7) + private val ignoreTime by option( "--ignore-time", "-t", help = "Ignore time differences." @@ -148,7 +155,7 @@ class CompareCommand : OrtCommand( "b/${fileB.relativeTo(commonParent).invariantSeparatorsPath}", linesA, DiffUtils.diff(linesA, linesB), - /* contextSize = */ 7 + contextSize ) if (diff.isEmpty()) {