summaryrefslogtreecommitdiffstats
path: root/src/options/set.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/options/set.rs')
-rw-r--r--src/options/set.rs25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/options/set.rs b/src/options/set.rs
index 1f0370b9..27aff042 100644
--- a/src/options/set.rs
+++ b/src/options/set.rs
@@ -22,9 +22,9 @@ macro_rules! set_options {
$opt:expr, $builtin_features:expr, $git_config:expr, $arg_matches:expr, $expected_option_name_map:expr, $check_names:expr) => {
let mut option_names = HashSet::new();
$(
- let kebab_case_field_name = stringify!($field_ident).replace("_", "-");
- let option_name = $expected_option_name_map[kebab_case_field_name.as_str()];
- if !$crate::config::user_supplied_option(&kebab_case_field_name, $arg_matches) {
+ let field_name = stringify!($field_ident);
+ let option_name = &$expected_option_name_map[field_name];
+ if !$crate::config::user_supplied_option(&field_name, $arg_matches) {
if let Some(value) = $crate::options::get::get_option_value(
option_name,
&$builtin_features,
@@ -35,7 +35,7 @@ macro_rules! set_options {
}
}
if $check_names {
- option_names.insert(option_name);
+ option_names.insert(option_name.as_str());
}
)*
if $check_names {
@@ -44,15 +44,16 @@ macro_rules! set_options {
"diff-highlight", // Does not exist as a flag on config
"diff-so-fancy", // Does not exist as a flag on config
"features", // Processed differently
- "help", // automatically added by clap
// Set prior to the rest
"no-gitconfig",
"dark",
"light",
"syntax-theme",
- "version", // automatically added by clap
]);
- let expected_option_names: HashSet<_> = $expected_option_name_map.values().cloned().collect();
+ let expected_option_names: HashSet<_> = $expected_option_name_map
+ .values()
+ .map(String::as_str)
+ .collect();
if option_names != expected_option_names {
$crate::config::delta_unreachable(
@@ -88,7 +89,7 @@ pub fn set_options(
// --color-only is used for interactive.diffFilter (git add -p) and side-by-side cannot be used
// there (does not emit lines in 1-1 correspondence with raw git output). See #274.
- if config::user_supplied_option("color-only", arg_matches) {
+ if config::user_supplied_option("color_only", arg_matches) {
builtin_features.remove("side-by-side");
}
@@ -101,12 +102,12 @@ pub fn set_options(
// HACK: make minus-line styles have syntax-highlighting iff side-by-side.
if features.contains(&"side-by-side".to_string()) {
let prefix = "normal ";
- if !config::user_supplied_option("minus-style", arg_matches)
+ if !config::user_supplied_option("minus_style", arg_matches)
&& opt.minus_style.starts_with(prefix)
{
opt.minus_style = format!("syntax {}", &opt.minus_style[prefix.len()..]);
}
- if !config::user_supplied_option("minus-emph-style", arg_matches)
+ if !config::user_supplied_option("minus_emph_style", arg_matches)
&& opt.minus_emph_style.starts_with(prefix)
{
opt.minus_emph_style = format!("syntax {}", &opt.minus_emph_style[prefix.len()..]);
@@ -115,7 +116,7 @@ pub fn set_options(
// Handle options which default to an arbitrary git config value.
// TODO: incorporate this logic into the set_options macro.
- if !config::user_supplied_option("whitespace-error-style", arg_matches) {
+ if !config::user_supplied_option("whitespace_error_style", arg_matches) {
opt.whitespace_error_style = if let Some(git_config) = git_config {
git_config.get::<String>("color.diff.whitespace")
} else {
@@ -251,7 +252,7 @@ fn set__light__dark__syntax_theme__options(
opt: &mut cli::Opt,
git_config: &mut Option<GitConfig>,
arg_matches: &clap::ArgMatches,
- option_names: &HashMap<&str, &str>,
+ option_names: &HashMap<String, String>,
) {
let validate_light_and_dark = |opt: &cli::Opt| {
if opt.light && opt.dark {