oli-obk / prettydiff

Side-by-side diff for two files
MIT License
33 stars 15 forks source link

Better programmatic use of prettytable #16

Closed asomers closed 3 months ago

asomers commented 1 year ago

Thank you so much for this crate! It's just what I need. It could be even better, though. The prettytable method looks like it's written solely with the CLI in mind, which makes it hard to use programmatically. Would it be possible:

If prettytable could do those things, then it would be perfect for my application. Which is, I want to print differences between large binary buffers in hex, as part of a test suite. First I format each buffer into hex, then use prettydiff to show the differences. I don't need line numbers because those are included in the hexdump. I do need to print to stderr instead of stdout, and some context would ease understanding. This is what it looks like right now: Screenshot_2023-09-09_09-59-16

romankoblov commented 1 year ago

written solely with the CLI in mind

Nope, it was done to be used as library, table is printed by this function, but you can format it yourself any way you want. CLI support was just nice to have feature.

  • Suppress line numbers.

This one should be possible by set_show_lines(false) on LineChangeset before prettytable call.

Would it be possible:

  • Allow printing to stderr or to a string instead of only stdout.
  • Suppress line numbers.
  • Show a few lines of context beside the mismatched lines

I personally don't need these features, but if you send PR I will merge it.

oli-obk commented 3 months ago

This was resolved by https://github.com/oli-obk/prettydiff/pull/17 afaict