summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorCatherine Noll <noll.catherine@gmail.com>2021-03-20 22:54:53 -0500
committerCatherine Noll <noll.catherine@gmail.com>2021-03-20 22:54:53 -0500
commitcc1bf64939f3ae6af21dc258e4a5aeb78d202ecb (patch)
treed3529e66774c8d473637eaeb9f3c4f0677b1ed27 /src/main.rs
parente561a51371365da845e13b91617cc0aaa2d92ef1 (diff)
Use a sample diff for displaying themes
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/main.rs b/src/main.rs
index 82e41536..b03b95a3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -22,6 +22,7 @@ mod options;
mod paint;
mod parse;
mod parse_style;
+mod sample_diff;
mod style;
mod syntect_color;
mod tests;
@@ -315,27 +316,19 @@ 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();
+ use sample_diff::DIFF;
+ let input = &DIFF.to_vec();
+
+ let mut git_config = git_config::GitConfig::try_create();
+ let opt = cli::Opt::from_iter_and_git_config(
+ &["", "", "--navigate"],
+ &mut git_config,
+ );
let mut output_type = OutputType::from_mode(
- PagingMode::QuitIfOneScreen,
+ PagingMode::Always,
None,
- &config::Config::from(cli::Opt::default()),
+ &config::Config::from(opt),
)
.unwrap();
let title_style = ansi_term::Style::new().bold();
@@ -345,7 +338,7 @@ index f38589a..0f1bb83 100644
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(),
+ &mut git_config,
);
let config = config::Config::from(opt);
if let Err(error) = delta(ByteLines::new(BufReader::new(&input[0..])), writer, &config) {