Skip to content

Add documentation on how to use Difflicious to print diffs from your own application code #171

@jportway

Description

@jportway

I had a situation where I wanted my application to be able to pretty-print a diff between the default configuration of the app and the actual resolved runtime configuration. It took quite a while to just find the method to generate the diff string because there's no mention of this use case in the documentation. The existing documentation assumes you are using Difflicious within a testing framework, which I don't think is always going to be the case.

Something like this in the cheatsheet maybe ? :

Printing diffs at runtime

if you want to use Difflicious in your own application rather than in a test suite, you can use the DiffResultPrinter

case class Config(outputPath: String, url:String, iterations:Int)
val defaultConfig = Config("/tmp/","google.com",100)
val config = Config("/tmp/","google.com",1000)

val diff = difflicious.Differ.apply[AppConfig].diff(defaultConfig, config)
System.log(s"Configuration resolved with overrides:\n${DiffResultPrinter.printDiffResult(diff)}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions