use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct ClockMode<'a> {
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
pub target_window: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_1_5")]
pub target_pane: Option<Cow<'a, str>>,
}
impl<'a> ClockMode<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
pub fn target_window<S: Into<Cow<'a, str>>>(mut self, target_window: S) -> Self {
self.target_window = Some(target_window.into());
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(CLOCK_MODE);
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
if let Some(target_window) = self.target_window {
cmd.push_option(T_LOWERCASE_KEY, target_window);
}
#[cfg(feature = "tmux_1_5")]
if let Some(target_pane) = self.target_pane {
cmd.push_option(T_LOWERCASE_KEY, target_pane);
}
cmd
}
}