summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cli.rs7
-rw-r--r--src/config.rs2
-rw-r--r--src/main.rs20
-rw-r--r--src/tests/integration_test_utils.rs2
4 files changed, 19 insertions, 12 deletions
diff --git a/src/cli.rs b/src/cli.rs
index a9a7cc34..414c04f5 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -1,7 +1,7 @@
use std::process;
use structopt::clap::AppSettings::{ColorAlways, ColoredHelp, DeriveDisplayOrder};
-use structopt::StructOpt;
+use structopt::{clap, StructOpt};
use crate::bat::assets::HighlightingAssets;
use crate::bat::output::PagingMode;
@@ -303,7 +303,10 @@ pub struct Opt {
pub deprecated_hunk_color: Option<String>,
}
-pub fn process_command_line_arguments<'a>(mut opt: Opt) -> config::Config<'a> {
+pub fn process_command_line_arguments<'a>(
+ mut opt: Opt,
+ arg_matches: Option<clap::ArgMatches>,
+) -> config::Config<'a> {
let assets = HighlightingAssets::new();
_check_validity(&opt, &assets);
diff --git a/src/config.rs b/src/config.rs
index 8a48096f..35961b34 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -373,7 +373,7 @@ mod tests {
options.dark = false;
}
}
- let config = cli::process_command_line_arguments(options);
+ let config = cli::process_command_line_arguments(options, None);
assert_eq!(config.theme_name, expected_theme);
if theme::is_no_syntax_highlighting_theme_name(expected_theme) {
assert!(config.theme.is_none())
diff --git a/src/main.rs b/src/main.rs
index 84f707d2..2384189e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -43,7 +43,8 @@ mod errors {
}
fn main() -> std::io::Result<()> {
- let opt = cli::Opt::from_args();
+ let arg_matches = cli::Opt::clap().get_matches();
+ let opt = cli::Opt::from_clap(&arg_matches);
if opt.list_languages {
list_languages()?;
@@ -58,7 +59,7 @@ fn main() -> std::io::Result<()> {
let show_background_colors_option = opt.show_background_colors;
- let config = cli::process_command_line_arguments(opt);
+ let config = cli::process_command_line_arguments(opt, Some(arg_matches));
if show_background_colors_option {
show_background_colors(&config);
@@ -137,12 +138,15 @@ index f38589a..0f1bb83 100644
}
writeln!(stdout, "\n\nTheme: {}\n", style.paint(theme))?;
- let config = cli::process_command_line_arguments(cli::Opt {
- theme: Some(theme.to_string()),
- file_style: "omit".to_string(),
- hunk_header_style: "omit".to_string(),
- ..opt.clone()
- });
+ let config = cli::process_command_line_arguments(
+ cli::Opt {
+ theme: Some(theme.to_string()),
+ file_style: "omit".to_string(),
+ hunk_header_style: "omit".to_string(),
+ ..opt.clone()
+ },
+ None,
+ );
let mut output_type = OutputType::from_mode(PagingMode::QuitIfOneScreen, None).unwrap();
let mut writer = output_type.handle().unwrap();
diff --git a/src/tests/integration_test_utils.rs b/src/tests/integration_test_utils.rs
index 1eefa33e..1b96537d 100644
--- a/src/tests/integration_test_utils.rs
+++ b/src/tests/integration_test_utils.rs
@@ -32,7 +32,7 @@ pub mod integration_test_utils {
pub fn run_delta<'a>(input: &str, options: cli::Opt) -> (String, config::Config<'a>) {
let mut writer: Vec<u8> = Vec::new();
- let config = cli::process_command_line_arguments(options);
+ let config = cli::process_command_line_arguments(options, None);
delta(
ByteLines::new(BufReader::new(input.as_bytes())),