diff options
author | Dan Davison <dandavison7@gmail.com> | 2020-08-01 10:37:06 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2020-08-01 11:38:19 -0400 |
commit | 5f97f327e3c0cae04790114190639cf929ec9810 (patch) | |
tree | a3535029ec25120584f29ac0b7708d34de96fad3 /src/options | |
parent | c6f66ab8fde78209d395d3502c63da66fae294e0 (diff) |
Add inspect-raw-lines {true,false} option
Fixes #72
Diffstat (limited to 'src/options')
-rw-r--r-- | src/options/set.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/options/set.rs b/src/options/set.rs index 02bd1ea3..7a67ef97 100644 --- a/src/options/set.rs +++ b/src/options/set.rs @@ -1,5 +1,6 @@ use std::collections::{HashMap, HashSet, VecDeque}; use std::process; +use std::result::Result; use std::str::FromStr; use console::Term; @@ -10,6 +11,7 @@ use crate::bat::output::PagingMode; use crate::cli; use crate::config; use crate::env; +use crate::errors::*; use crate::features; use crate::git_config; use crate::git_config_entry::{self, GitConfigEntry}; @@ -128,6 +130,7 @@ pub fn set_options( hunk_header_style, hyperlinks, hyperlinks_file_link_format, + inspect_raw_lines, keep_plus_minus_markers, max_line_distance, // Hack: minus-style must come before minus-*emph-style because the latter default @@ -170,6 +173,8 @@ pub fn set_options( true ); + opt.computed.inspect_raw_lines = + cli::InspectRawLines::from_str(&opt.inspect_raw_lines).unwrap(); opt.computed.paging_mode = parse_paging_mode(&opt.paging_mode); } @@ -463,6 +468,23 @@ fn is_truecolor_terminal() -> bool { .unwrap_or(false) } +impl FromStr for cli::InspectRawLines { + type Err = Error; + fn from_str(s: &str) -> Result<Self, Self::Err> { + match s.to_lowercase().as_str() { + "true" => Ok(Self::True), + "false" => Ok(Self::False), + _ => { + eprintln!( + r#"Invalid value for inspect-raw-lines option: {}. Valid values are "true", and "false"."#, + s + ); + process::exit(1); + } + } + } +} + fn parse_paging_mode(paging_mode_string: &str) -> PagingMode { match paging_mode_string.to_lowercase().as_str() { "always" => PagingMode::Always, |