Skip to content

Commit

Permalink
feat(compare-command): Make the context size configurable via an option
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Nov 28, 2023
1 parent e85b5eb commit b1d1ae1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion plugins/commands/compare/src/main/kotlin/CompareCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -70,6 +71,12 @@ class CompareCommand : OrtCommand(
).enum<CompareMethod>()
.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."
Expand Down Expand Up @@ -148,7 +155,7 @@ class CompareCommand : OrtCommand(
"b/${fileB.relativeTo(commonParent).invariantSeparatorsPath}",
linesA,
DiffUtils.diff(linesA, linesB),
/* contextSize = */ 7
contextSize
)

if (diff.isEmpty()) {
Expand Down

0 comments on commit b1d1ae1

Please sign in to comment.