use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct ChooseClient<'a> {
#[cfg(feature = "tmux_2_6")]
pub without_preview: bool,
#[cfg(feature = "tmux_3_1")]
pub reverse_sort_order: bool,
#[cfg(feature = "tmux_3_6")]
pub disable_confirmation: bool,
#[cfg(feature = "tmux_2_7")]
pub zoom: bool,
#[cfg(feature = "tmux_1_7")]
pub format: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_2_6")]
pub filter: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_3_2")]
pub key_format: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_2_6")]
pub sort_order: Option<Cow<'a, str>>,
#[cfg(all(feature = "tmux_1_5", not(feature = "tmux_2_6")))]
pub target_window: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_2_6")]
pub target_pane: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_1_5")]
pub template: Option<Cow<'a, str>>,
}
impl<'a> ChooseClient<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_2_6")]
pub fn without_preview(mut self) -> Self {
self.without_preview = true;
self
}
#[cfg(feature = "tmux_3_1")]
pub fn reverse_sort_order(mut self) -> Self {
self.reverse_sort_order = true;
self
}
#[cfg(feature = "tmux_3_6")]
pub fn disable_confirmation(mut self) -> Self {
self.disable_confirmation = true;
self
}
#[cfg(feature = "tmux_2_7")]
pub fn zoom(mut self) -> Self {
self.zoom = true;
self
}
#[cfg(feature = "tmux_1_7")]
pub fn format<S: Into<Cow<'a, str>>>(mut self, format: S) -> Self {
self.format = Some(format.into());
self
}
#[cfg(feature = "tmux_2_6")]
pub fn filter<S: Into<Cow<'a, str>>>(mut self, filter: S) -> Self {
self.filter = Some(filter.into());
self
}
#[cfg(feature = "tmux_3_2")]
pub fn key_format<S: Into<Cow<'a, str>>>(mut self, key_format: S) -> Self {
self.key_format = Some(key_format.into());
self
}
#[cfg(feature = "tmux_2_6")]
pub fn sort_order<S: Into<Cow<'a, str>>>(mut self, sort_order: S) -> Self {
self.sort_order = Some(sort_order.into());
self
}
#[cfg(all(feature = "tmux_1_5", not(feature = "tmux_2_6")))]
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_2_6")]
pub fn target_pane<S: Into<Cow<'a, str>>>(mut self, target_pane: S) -> Self {
self.target_pane = Some(target_pane.into());
self
}
#[cfg(feature = "tmux_1_5")]
pub fn template<S: Into<Cow<'a, str>>>(mut self, template: S) -> Self {
self.template = Some(template.into());
self
}
pub fn build(self) -> TmuxCommand<'a> {
let mut cmd = TmuxCommand::new();
cmd.name(CHOOSE_CLIENT);
#[cfg(feature = "tmux_2_6")]
if self.without_preview {
cmd.push_flag(N_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_3_1")]
if self.reverse_sort_order {
cmd.push_flag(R_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_3_6")]
if self.disable_confirmation {
cmd.push_flag(Y_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_2_7")]
if self.zoom {
cmd.push_flag(Z_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_1_7")]
if let Some(format) = self.format {
cmd.push_option(F_UPPERCASE_KEY, format);
}
#[cfg(feature = "tmux_2_6")]
if let Some(filter) = self.filter {
cmd.push_option(F_LOWERCASE_KEY, filter);
}
#[cfg(feature = "tmux_3_2")]
if let Some(key_format) = self.key_format {
cmd.push_option(K_UPPERCASE_KEY, key_format);
}
#[cfg(feature = "tmux_2_6")]
if let Some(sort_order) = self.sort_order {
cmd.push_option(O_UPPERCASE_KEY, sort_order);
}
#[cfg(all(feature = "tmux_1_5", not(feature = "tmux_2_6")))]
if let Some(target_window) = self.target_window {
cmd.push_option(T_LOWERCASE_KEY, target_window);
}
#[cfg(feature = "tmux_2_6")]
if let Some(target_pane) = self.target_pane {
cmd.push_option(T_LOWERCASE_KEY, target_pane);
}
#[cfg(feature = "tmux_1_5")]
if let Some(template) = self.template {
cmd.push_param(template);
}
cmd
}
}