use psdk_father::args::{ArgContext, PsdkArgBase, PsdkEasyArg};
use psdk_father::command::CommandClause;
use psdk_father::errors::PsdkFatherResult;
use std::sync::{Arc, Mutex};

#[derive(Clone, Debug)]
pub struct TSelfTest {
  ctx: Arc<Mutex<ArgContext>>,
}

impl Default for TSelfTest {
  fn default() -> Self {
    Self::new()
  }
}

impl TSelfTest {
  pub fn new() -> Self {
    Self {
      ctx: Default::default(),
    }
  }
}

impl PsdkEasyArg<String> for TSelfTest {
  fn context(&self) -> Arc<Mutex<ArgContext>> {
    self.ctx.clone()
  }
}

impl PsdkArgBase<String> for TSelfTest {
  fn header(&self) -> String {
    "SELFTEST".to_string()
  }

  fn clause(&self) -> PsdkFatherResult<CommandClause> {
    Ok(CommandClause::with_text(self.header()))
  }
}

psdk_father::impl_psdk_arg_to_easy_arg!(String, TSelfTest, true);
