diff options
author | Catherine Noll <noll.catherine@gmail.com> | 2021-03-20 20:39:01 -0500 |
---|---|---|
committer | Catherine Noll <noll.catherine@gmail.com> | 2021-03-20 22:53:31 -0500 |
commit | e561a51371365da845e13b91617cc0aaa2d92ef1 (patch) | |
tree | e92ed22a7a094ab5b58ba0e47df3ed39927cf4ce /src | |
parent | 0c1b7b89b025aacfe12a418e067f449a9a0946fa (diff) |
Apply themes to a hardcoded diff
Diffstat (limited to 'src')
-rw-r--r-- | src/cli.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 30 |
2 files changed, 30 insertions, 2 deletions
@@ -1,5 +1,4 @@ use std::collections::{HashMap, HashSet}; -#[cfg(test)] use std::ffi::OsString; use std::path::PathBuf; @@ -641,7 +640,6 @@ impl Opt { Self::from_clap_and_git_config(Self::clap().get_matches(), git_config, assets) } - #[cfg(test)] pub fn from_iter_and_git_config<I>(iter: I, git_config: &mut Option<GitConfig>) -> Self where I: IntoIterator, diff --git a/src/main.rs b/src/main.rs index 8fd8dd10..82e41536 100644 --- a/src/main.rs +++ b/src/main.rs @@ -313,6 +313,25 @@ const THEMES: [&'static str; 4] = [ ]; fn show_themes() -> std::io::Result<()> { + use bytelines::ByteLines; + use std::io::BufReader; + let input = b"\ +diff --git a/example.rs b/example.rs +index f38589a..0f1bb83 100644 +--- a/example.rs ++++ b/example.rs +@@ -1,5 +1,5 @@ +-// Output the square of a number. +-fn print_square(num: f64) { +- let result = f64::powf(num, 2.0); +- println!(\"The square of {:.2} is {:.2}.\", num, result); ++// Output the cube of a number. ++fn print_cube(num: f64) { ++ let result = f64::powf(num, 3.0); ++ println!(\"The cube of {:.2} is {:.2}.\", num, result); +" + .to_vec(); + let mut output_type = OutputType::from_mode( PagingMode::QuitIfOneScreen, None, @@ -324,6 +343,17 @@ fn show_themes() -> std::io::Result<()> { for theme in &THEMES { writeln!(writer, "\n\nTheme: {}\n", title_style.paint(*theme))?; + let opt = cli::Opt::from_iter_and_git_config( + &["", "", "--features", theme], + &mut git_config::GitConfig::try_create(), + ); + let config = config::Config::from(opt); + if let Err(error) = delta(ByteLines::new(BufReader::new(&input[0..])), writer, &config) { + match error.kind() { + ErrorKind::BrokenPipe => process::exit(0), + _ => eprintln!("{}", error), + } + }; } Ok(()) |