From b0680671b7e2212164bea29683f2335386fa1e92 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 | 10 +++++++++- 1 file changed, 9 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..c39311424aa46 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,13 @@ class CompareCommand : OrtCommand( ).enum() .default(CompareMethod.TEXT_DIFF) + private val contextSize by option( + "--context-size", "-C", + help = "The number of unmodified lines to display in the context of a modified line. Only applies to unified " + + "diff output." + ).int() + .default(7) + private val ignoreTime by option( "--ignore-time", "-t", help = "Ignore time differences." @@ -148,7 +156,7 @@ class CompareCommand : OrtCommand( "b/${fileB.relativeTo(commonParent).invariantSeparatorsPath}", linesA, DiffUtils.diff(linesA, linesB), - /* contextSize = */ 7 + contextSize ) if (diff.isEmpty()) {