use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct ChooseTree<'a> {
#[cfg(feature = "tmux_2_7")]
pub all: bool,
#[cfg(feature = "tmux_2_6")]
pub without_preview: bool,
#[cfg(feature = "tmux_3_1")]
pub reverse_sort_order: bool,
#[cfg(feature = "tmux_1_7")]
pub collapsed_sessions: bool,
#[cfg(all(feature = "tmux_1_8", not(feature = "tmux_2_6")))]
pub expanded_sessions: bool,
#[cfg(feature = "tmux_1_7")]
pub collapsed_windows: bool,
#[cfg(feature = "tmux_3_6")]
pub disable_confirmation: bool,
#[cfg(feature = "tmux_2_7")]
pub zoom: bool,
#[cfg(feature = "tmux_2_6")]
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_7", not(feature = "tmux_2_6")))]
pub session_template: Option<Cow<'a, str>>,
#[cfg(all(feature = "tmux_1_7", not(feature = "tmux_2_6")))]
pub window_template: Option<Cow<'a, str>>,
#[cfg(all(feature = "tmux_1_7", not(feature = "tmux_2_6")))]
pub session_format: Option<Cow<'a, str>>,
#[cfg(all(feature = "tmux_1_7", not(feature = "tmux_2_6")))]
pub window_format: Option<Cow<'a, str>>,
#[cfg(all(feature = "tmux_1_7", 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_2_6")]
pub template: Option<Cow<'a, str>>,
}
impl<'a> ChooseTree<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_2_7")]
pub fn all(mut self) -> Self {
self.all = true;
self
}
#[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_1_7")]
pub fn collapsed_sessions(mut self) -> Self {
self.collapsed_sessions = true;
self
}
#[cfg(all(feature = "tmux_1_8", not(feature = "tmux_2_6")))]
pub fn expanded_sessions(mut self) -> Self {
self.expanded_sessions = true;
self
}
#[cfg(feature = "tmux_1_7")]
pub fn collapsed_windows(mut self) -> Self {
self.collapsed_windows = 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_2_6")]
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_7", not(feature = "tmux_2_6")))]
pub fn session_template<S: Into<Cow<'a, str>>>(mut self, session_template: S) -> Self {
self.session_template = Some(session_template.into());
self
}
#[cfg(all(feature = "tmux_1_7", not(feature = "tmux_2_6")))]
pub fn window_template<S: Into<Cow<'a, str>>>(mut self, window_template: S) -> Self {
self.window_template = Some(window_template.into());
self
}
#[cfg(all(feature = "tmux_1_7", not(feature = "tmux_2_6")))]
pub fn session_format<S: Into<Cow<'a, str>>>(mut self, session_format: S) -> Self {
self.session_format = Some(session_format.into());
self
}
#[cfg(all(feature = "tmux_1_7", not(feature = "tmux_2_6")))]
pub fn window_format<S: Into<Cow<'a, str>>>(mut self, window_format: S) -> Self {
self.window_format = Some(window_format.into());
self
}
#[cfg(all(feature = "tmux_1_7", 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_2_6")]
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_TREE);
#[cfg(feature = "tmux_2_7")]
if self.all {
cmd.push_flag(G_UPPERCASE_KEY);
}
#[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_1_7")]
if self.collapsed_sessions {
cmd.push_flag(S_LOWERCASE_KEY);
}
#[cfg(all(feature = "tmux_1_8", not(feature = "tmux_2_6")))]
if self.expanded_sessions {
cmd.push_flag(U_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_1_7")]
if self.collapsed_windows {
cmd.push_flag(W_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_2_6")]
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_7", not(feature = "tmux_2_6")))]
if let Some(session_template) = self.session_template {
cmd.push_option(B_LOWERCASE_KEY, session_template);
}
#[cfg(all(feature = "tmux_1_7", not(feature = "tmux_2_6")))]
if let Some(window_template) = self.window_template {
cmd.push_option(C_LOWERCASE_KEY, window_template);
}
#[cfg(all(feature = "tmux_1_7", not(feature = "tmux_2_6")))]
if let Some(format) = self.session_format {
cmd.push_option(S_UPPERCASE_KEY, format);
}
#[cfg(all(feature = "tmux_1_7", not(feature = "tmux_2_6")))]
if let Some(format) = self.window_format {
cmd.push_option(W_UPPERCASE_KEY, format);
}
#[cfg(all(feature = "tmux_1_7", 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_2_6")]
if let Some(template) = self.template {
cmd.push_param(template);
}
cmd
}
}