1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
//! This library is for helping you create diff for displaying on the terminal
//!
//! # Examples
//!
//! ```
//! use termdiff::{arrows_theme, diff};
//! let old = "Double, double toil and trouble;
//! Fire burn and
//! Caldron bubble.";
//! let new = "Double, double toil and trouble;
//! Fire burn and
//! caldron bubble.
//! Cool it with a baboon's blood,
//! Then the charm is firm and good.";
//! let mut buffer: Vec<u8> = Vec::new();
//! diff(&mut buffer, old, new, arrows_theme()).unwrap();
//! let actual: String = String::from_utf8(buffer).expect("Not valid UTF-8");
//!
//! assert_eq!(
//! actual,
//! "< left / > right
//! Double, double toil and trouble;
//! Fire burn and
//! <Caldron bubble.
//! >caldron bubble.
//! >Cool it with a baboon's blood,
//! >Then the charm is firm and good.
//! "
//! );
//! ```
//!
//! Alternatively if you are dropping this into a `format!` or similar, you
//! might want to use the displayable instead
//!
//! ```
//! use termdiff::{signs_theme, DrawDiff};
//! let old = "Double, double toil and trouble;
//! Fire burn and
//! Caldron bubble.";
//! let new = "Double, double toil and trouble;
//! Fire burn and
//! caldron bubble.
//! Cool it with a baboon's blood,
//! Then the charm is firm and good.";
//! let actual = format!("{}", DrawDiff::new(old, new, signs_theme()));
//!
//! assert_eq!(
//! actual,
//! "--- remove | insert +++
//! Double, double toil and trouble;
//! Fire burn and
//! -Caldron bubble.
//! +caldron bubble.
//! +Cool it with a baboon's blood,
//! +Then the charm is firm and good.
//! "
//! );
//! ```
mod cmd;
mod draw_diff;
mod themes;
pub use cmd::diff;
pub use draw_diff::DrawDiff;
pub use themes::{arrows_color_theme, arrows_theme, signs_color_theme, signs_theme, Theme};