pubgrub-rs / pubgrub

PubGrub version solving algorithm implemented in Rust
https://pubgrub-rs.github.io/pubgrub/pubgrub/
Mozilla Public License 2.0
337 stars 30 forks source link

feat: add report formatter trait for custom reporter output #158

Closed zanieb closed 7 months ago

zanieb commented 7 months ago

Adds a ReportFormatter trait and a Reporter::report_with_formatter method allowing customization of formatting the report without reimplementing reporter internals. Currently, we use format_external and format_terms but we can refine formatting in the future as needed e.g. all the explain methods in the reporter.

Adds a DefaultStringReportFormatter which implements the existing format for the DefaultStringReporter.

You can see how much easier this is to use in the example diff at https://github.com/pubgrub-rs/pubgrub/commit/725ec87c7ef7b1a7efbe90f91375b8d685318aa2

Some existing discussion at https://github.com/zanieb/pubgrub/pull/10

Addresses some of the concerns in https://github.com/pubgrub-rs/pubgrub/issues/150

mpizenberg commented 7 months ago

I like it a lot too!

mpizenberg commented 7 months ago

Nothing to add, this is great!