use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
pub type ClearHist<'a> = ClearHistory<'a>;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct ClearHistory<'a> {
#[cfg(feature = "tmux_3_4")]
pub no_hyperlinks: bool,
#[cfg(feature = "tmux_1_5")]
pub target_pane: Option<Cow<'a, str>>,
}
impl<'a> ClearHistory<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_3_4")]
pub fn no_hyperlinks(mut self) -> Self {
self.no_hyperlinks = true;
self
}
#[cfg(feature = "tmux_1_5")]
pub fn target_pane<S: Into<Cow<'a, str>>>(mut self, target_pane: S) -> Self {
self.target_pane = Some(target_pane.into());
self
}
pub fn build(self) -> TmuxCommand<'a> {
let mut cmd = TmuxCommand::new();
cmd.name(CLEAR_HISTORY);
#[cfg(feature = "tmux_3_4")]
if self.no_hyperlinks {
cmd.push_flag(H_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_5")]
if let Some(target_pane) = self.target_pane {
cmd.push_option(T_LOWERCASE_KEY, target_pane);
}
cmd
}
}