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