Skip to content

Commit 3ed6cf0

Browse files
authored
Add --summary-only flag (#471)
1 parent 6695658 commit 3ed6cf0

18 files changed

Lines changed: 42 additions & 20 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
## [Unreleased]
44
[Unreleased]: https://github.com/JakeWharton/diffuse/compare/0.3.0...HEAD
5-
5+
**Added**
6+
- Add `--summary-only` flag.
67

78
## [0.3.0] - 2024-02-20
89
[0.3.0]: https://github.com/JakeWharton/diffuse/releases/tag/0.3.0

diffuse/src/main/kotlin/com/jakewharton/diffuse/diffuse.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,16 @@ private class OutputOptions(outputFs: FileSystem, private val output: PrintStrea
127127
}
128128
}
129129

130+
private val summaryOnly by
131+
option(
132+
"--summary-only",
133+
help = "Skip generating detailed reports, outputting only the summary.",
134+
)
135+
.flag()
136+
130137
fun write(reportFactory: Report.Factory) {
131-
val textReport by lazy(NONE) { reportFactory.toTextReport().toString() }
132-
val htmlReport by lazy(NONE) { reportFactory.toHtmlReport().toString() }
138+
val textReport by lazy(NONE) { reportFactory.toTextReport(summaryOnly).toString() }
139+
val htmlReport by lazy(NONE) { reportFactory.toHtmlReport(summaryOnly).toString() }
133140

134141
text?.writeText(textReport)
135142
html?.writeText(htmlReport)

reports/src/main/kotlin/com/jakewharton/diffuse/diff/AabDiff.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ internal class AabDiff(val oldAab: Aab, val newAab: Aab) : BinaryDiff {
2929
ModuleDiff(oldModule, newAab.featureModules.getValue(name))
3030
}
3131

32-
override fun toTextReport(): Report = AabDiffTextReport(this)
32+
override fun toTextReport(summaryOnly: Boolean): Report = AabDiffTextReport(this, summaryOnly)
3333
}

reports/src/main/kotlin/com/jakewharton/diffuse/diff/AarDiff.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ internal class AarDiff(
1515
val jars = JarsDiff(oldAar.jars, oldMapping, newAar.jars, newMapping)
1616
val manifest = ManifestDiff(oldAar.manifest, newAar.manifest)
1717

18-
override fun toTextReport(): Report = AarDiffTextReport(this)
18+
override fun toTextReport(summaryOnly: Boolean): Report = AarDiffTextReport(this, summaryOnly)
1919
}

reports/src/main/kotlin/com/jakewharton/diffuse/diff/ApkDiff.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ internal class ApkDiff(
2424

2525
val lintMessages = listOfNotNull(archive.resourcesArscCompression())
2626

27-
override fun toTextReport(): Report = ApkDiffTextReport(this)
27+
override fun toTextReport(summaryOnly: Boolean): Report = ApkDiffTextReport(this, summaryOnly)
2828
}

reports/src/main/kotlin/com/jakewharton/diffuse/diff/DexDiff.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal class DexDiff(val oldDexes: List<Dex>, val newDexes: List<Dex>) : Binar
3232

3333
val changed = strings.changed || types.changed || methods.changed || fields.changed
3434

35-
override fun toTextReport(): Report = DexDiffTextReport(this)
35+
override fun toTextReport(summaryOnly: Boolean): Report = DexDiffTextReport(this, summaryOnly)
3636
}
3737

3838
internal fun DexDiff.toSummaryTable() =

reports/src/main/kotlin/com/jakewharton/diffuse/diff/JarDiff.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ internal class JarDiff(
1616

1717
val changed = jars.changed || archive.changed
1818

19-
override fun toTextReport(): Report = JarDiffTextReport(this)
19+
override fun toTextReport(summaryOnly: Boolean): Report = JarDiffTextReport(this, summaryOnly)
2020
}

reports/src/main/kotlin/com/jakewharton/diffuse/info/AabInfo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import com.jakewharton.diffuse.report.Report
66
import com.jakewharton.diffuse.report.text.AabInfoTextReport
77

88
class AabInfo(private val aab: Aab) : BinaryDiff {
9-
override fun toTextReport(): Report {
9+
override fun toTextReport(summaryOnly: Boolean): Report {
1010
return AabInfoTextReport(aab)
1111
}
1212
}

reports/src/main/kotlin/com/jakewharton/diffuse/info/AarInfo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import com.jakewharton.diffuse.report.Report
55
import com.jakewharton.diffuse.report.text.AarInfoTextReport
66

77
class AarInfo(private val aar: Aar) : BinaryInfo {
8-
override fun toTextReport(): Report {
8+
override fun toTextReport(summaryOnly: Boolean): Report {
99
return AarInfoTextReport(aar)
1010
}
1111
}

reports/src/main/kotlin/com/jakewharton/diffuse/info/ApkInfo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import com.jakewharton.diffuse.report.Report
55
import com.jakewharton.diffuse.report.text.ApkInfoTextReport
66

77
class ApkInfo(private val apk: Apk) : BinaryInfo {
8-
override fun toTextReport(): Report {
8+
override fun toTextReport(summaryOnly: Boolean): Report {
99
return ApkInfoTextReport(apk)
1010
}
1111
}

0 commit comments

Comments
 (0)