From f539545eddb014205225b0f960469846c43b9f04 Mon Sep 17 00:00:00 2001 From: graelo Date: Sun, 21 Mar 2021 08:03:40 +0100 Subject: [PATCH] refactor: HintStyleCli -> HintStyleArg --- src/config/core.rs | 12 ++++++------ src/config/mod.rs | 2 +- src/lib.rs | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/config/core.rs b/src/config/core.rs index 9e3795e..7f94e4c 100644 --- a/src/config/core.rs +++ b/src/config/core.rs @@ -62,7 +62,7 @@ pub struct CliOpt { /// Underline or surround the hint for increased visibility. /// If not provided, only the hint colors will be used. #[clap(short = 's', long, arg_enum)] - pub hint_style: Option, + pub hint_style: Option, /// Chars surrounding each hint, used with `Surround` style. #[clap(long, default_value = "{}", @@ -77,20 +77,20 @@ pub struct CliOpt { /// Type introduced due to parsing limitation, /// as we cannot directly parse into ui::HintStyle. #[derive(Debug, Clap)] -pub enum HintStyleCli { +pub enum HintStyleArg { Bold, Italic, Underline, Surround, } -impl FromStr for HintStyleCli { +impl FromStr for HintStyleArg { type Err = error::ParseError; fn from_str(s: &str) -> Result { match s { - "leading" => Ok(HintStyleCli::Underline), - "trailing" => Ok(HintStyleCli::Surround), + "leading" => Ok(HintStyleArg::Underline), + "trailing" => Ok(HintStyleArg::Surround), _ => Err(error::ParseError::ExpectedString(String::from( "underline or surround", ))), @@ -140,7 +140,7 @@ impl CliOpt { "@copyrat-hint-alignment" => { self.hint_alignment = ui::HintAlignment::from_str(&value)? } - "@copyrat-hint-style" => self.hint_style = Some(HintStyleCli::from_str(&value)?), + "@copyrat-hint-style" => self.hint_style = Some(HintStyleArg::from_str(&value)?), // Ignore unknown options. _ => (), diff --git a/src/config/mod.rs b/src/config/mod.rs index 13b14a4..7163ce7 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -2,4 +2,4 @@ mod bridge; mod core; pub use self::bridge::BridgeOpt; -pub use self::core::{CliOpt, HintStyleCli}; +pub use self::core::{CliOpt, HintStyleArg}; diff --git a/src/lib.rs b/src/lib.rs index 42535d6..944a499 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,10 +22,10 @@ pub fn run(buffer: String, opt: &config::CliOpt) -> Option { let hint_style = match &opt.hint_style { None => None, Some(style) => match style { - config::HintStyleCli::Bold => Some(ui::HintStyle::Bold), - config::HintStyleCli::Italic => Some(ui::HintStyle::Italic), - config::HintStyleCli::Underline => Some(ui::HintStyle::Underline), - config::HintStyleCli::Surround => { + config::HintStyleArg::Bold => Some(ui::HintStyle::Bold), + config::HintStyleArg::Italic => Some(ui::HintStyle::Italic), + config::HintStyleArg::Underline => Some(ui::HintStyle::Underline), + config::HintStyleArg::Surround => { let (open, close) = opt.hint_surroundings; Some(ui::HintStyle::Surround(open, close)) }