mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-12 08:00:08 +01:00
refactor: HintStyleCli -> HintStyleArg
This commit is contained in:
parent
5d4f19d7ba
commit
f539545edd
3 changed files with 11 additions and 11 deletions
|
|
@ -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<HintStyleCli>,
|
||||
pub hint_style: Option<HintStyleArg>,
|
||||
|
||||
/// 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<Self, error::ParseError> {
|
||||
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.
|
||||
_ => (),
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ pub fn run(buffer: String, opt: &config::CliOpt) -> Option<ui::Selection> {
|
|||
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))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue