mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-12 16:10:07 +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.
|
/// Underline or surround the hint for increased visibility.
|
||||||
/// If not provided, only the hint colors will be used.
|
/// If not provided, only the hint colors will be used.
|
||||||
#[clap(short = 's', long, arg_enum)]
|
#[clap(short = 's', long, arg_enum)]
|
||||||
pub hint_style: Option<HintStyleCli>,
|
pub hint_style: Option<HintStyleArg>,
|
||||||
|
|
||||||
/// Chars surrounding each hint, used with `Surround` style.
|
/// Chars surrounding each hint, used with `Surround` style.
|
||||||
#[clap(long, default_value = "{}",
|
#[clap(long, default_value = "{}",
|
||||||
|
|
@ -77,20 +77,20 @@ pub struct CliOpt {
|
||||||
/// Type introduced due to parsing limitation,
|
/// Type introduced due to parsing limitation,
|
||||||
/// as we cannot directly parse into ui::HintStyle.
|
/// as we cannot directly parse into ui::HintStyle.
|
||||||
#[derive(Debug, Clap)]
|
#[derive(Debug, Clap)]
|
||||||
pub enum HintStyleCli {
|
pub enum HintStyleArg {
|
||||||
Bold,
|
Bold,
|
||||||
Italic,
|
Italic,
|
||||||
Underline,
|
Underline,
|
||||||
Surround,
|
Surround,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for HintStyleCli {
|
impl FromStr for HintStyleArg {
|
||||||
type Err = error::ParseError;
|
type Err = error::ParseError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, error::ParseError> {
|
fn from_str(s: &str) -> Result<Self, error::ParseError> {
|
||||||
match s {
|
match s {
|
||||||
"leading" => Ok(HintStyleCli::Underline),
|
"leading" => Ok(HintStyleArg::Underline),
|
||||||
"trailing" => Ok(HintStyleCli::Surround),
|
"trailing" => Ok(HintStyleArg::Surround),
|
||||||
_ => Err(error::ParseError::ExpectedString(String::from(
|
_ => Err(error::ParseError::ExpectedString(String::from(
|
||||||
"underline or surround",
|
"underline or surround",
|
||||||
))),
|
))),
|
||||||
|
|
@ -140,7 +140,7 @@ impl CliOpt {
|
||||||
"@copyrat-hint-alignment" => {
|
"@copyrat-hint-alignment" => {
|
||||||
self.hint_alignment = ui::HintAlignment::from_str(&value)?
|
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.
|
// Ignore unknown options.
|
||||||
_ => (),
|
_ => (),
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@ mod bridge;
|
||||||
mod core;
|
mod core;
|
||||||
|
|
||||||
pub use self::bridge::BridgeOpt;
|
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 {
|
let hint_style = match &opt.hint_style {
|
||||||
None => None,
|
None => None,
|
||||||
Some(style) => match style {
|
Some(style) => match style {
|
||||||
config::HintStyleCli::Bold => Some(ui::HintStyle::Bold),
|
config::HintStyleArg::Bold => Some(ui::HintStyle::Bold),
|
||||||
config::HintStyleCli::Italic => Some(ui::HintStyle::Italic),
|
config::HintStyleArg::Italic => Some(ui::HintStyle::Italic),
|
||||||
config::HintStyleCli::Underline => Some(ui::HintStyle::Underline),
|
config::HintStyleArg::Underline => Some(ui::HintStyle::Underline),
|
||||||
config::HintStyleCli::Surround => {
|
config::HintStyleArg::Surround => {
|
||||||
let (open, close) = opt.hint_surroundings;
|
let (open, close) = opt.hint_surroundings;
|
||||||
Some(ui::HintStyle::Surround(open, close))
|
Some(ui::HintStyle::Surround(open, close))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue