use std::sync::{Arc, Mutex};
use psdk_father::{
args::{ArgContext, PsdkArgBase, PsdkEasyArg},
command::{CommandClause, PsdkTextCommand},
errors::PsdkFatherResult,
};
#[derive(Clone, Debug)]
pub struct CUnderLineOptions {
pub enable: bool,
}
#[derive(Clone, Debug)]
pub struct CUnderLine {
options: CUnderLineOptions,
ctx: Arc<Mutex<ArgContext>>,
}
impl CUnderLine {
pub fn new(options: CUnderLineOptions) -> Self {
Self {
options,
ctx: Default::default(),
}
}
}
impl PsdkEasyArg<String> for CUnderLine {
fn context(&self) -> Arc<Mutex<ArgContext>> {
self.ctx.clone()
}
}
impl PsdkArgBase<String> for CUnderLine {
fn header(&self) -> String {
"UNDERLINE".to_string()
}
fn clause(&self) -> PsdkFatherResult<CommandClause> {
let mut ptc = PsdkTextCommand::with_header_format_cpcl(self.header());
ptc.append(if self.options.enable { "ON" } else { "OFF" });
Ok(ptc.clause())
}
}
psdk_father::impl_psdk_arg_to_easy_arg!(String, CUnderLine, true);