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 b068067
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 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,13 @@ class CompareCommand : OrtCommand(
).enum<CompareMethod>()
.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."
Expand Down Expand Up @@ -148,7 +156,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 b068067

Please sign in to comment.