use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
pub type ShowMsgs<'a> = ShowMessages<'a>;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct ShowMessages<'a> {
#[cfg(all(feature = "tmux_1_9", not(feature = "tmux_2_2")))]
pub server: bool,
#[cfg(feature = "tmux_1_9")]
pub jobs: bool,
#[cfg(feature = "tmux_1_9")]
pub terminals: bool,
#[cfg(feature = "tmux_1_2")]
pub target_client: Option<Cow<'a, str>>,
}
impl<'a> ShowMessages<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(all(feature = "tmux_1_9", not(feature = "tmux_2_2")))]
pub fn server(mut self) -> Self {
self.server = true;
self
}
#[cfg(feature = "tmux_1_9")]
pub fn jobs(mut self) -> Self {
self.jobs = true;
self
}
#[cfg(feature = "tmux_1_9")]
pub fn terminals(mut self) -> Self {
self.terminals = true;
self
}
#[cfg(feature = "tmux_1_2")]
pub fn target_client<S: Into<Cow<'a, str>>>(mut self, target_client: S) -> Self {
self.target_client = Some(target_client.into());
self
}
pub fn build(self) -> TmuxCommand<'a> {
let mut cmd = TmuxCommand::new();
cmd.name(SHOW_MESSAGES);
#[cfg(all(feature = "tmux_1_9", not(feature = "tmux_2_2")))]
if self.server {
cmd.push_flag(I_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_9")]
if self.jobs {
cmd.push_flag(J_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_9")]
if self.terminals {
cmd.push_flag(T_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_2")]
if let Some(target_client) = self.target_client {
cmd.push_option(T_LOWERCASE_KEY, target_client);
}
cmd
}
}