use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
pub type ShowEnv<'a> = ShowEnvironment<'a>;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct ShowEnvironment<'a> {
#[cfg(feature = "tmux_3_2")]
pub hidden: bool,
#[cfg(feature = "tmux_1_0")]
pub global: bool,
#[cfg(feature = "tmux_2_1")]
pub as_shell_commands: bool,
#[cfg(feature = "tmux_1_0")]
pub target_session: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_1_7")]
pub variable: Option<Cow<'a, str>>,
}
impl<'a> ShowEnvironment<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_3_2")]
pub fn hidden(mut self) -> Self {
self.hidden = true;
self
}
#[cfg(feature = "tmux_1_0")]
pub fn global(mut self) -> Self {
self.global = true;
self
}
#[cfg(feature = "tmux_2_1")]
pub fn as_shell_commands(mut self) -> Self {
self.as_shell_commands = true;
self
}
#[cfg(feature = "tmux_1_0")]
pub fn target_session<S: Into<Cow<'a, str>>>(mut self, target_session: S) -> Self {
self.target_session = Some(target_session.into());
self
}
#[cfg(feature = "tmux_1_7")]
pub fn variable<S: Into<Cow<'a, str>>>(mut self, variable: S) -> Self {
self.variable = Some(variable.into());
self
}
pub fn build(self) -> TmuxCommand<'a> {
let mut cmd = TmuxCommand::new();
cmd.name(SHOW_ENVIRONMENT);
#[cfg(feature = "tmux_3_2")]
if self.hidden {
cmd.push_flag(H_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_1_0")]
if self.global {
cmd.push_flag(G_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_2_1")]
if self.as_shell_commands {
cmd.push_flag(S_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_1_0")]
if let Some(target_session) = self.target_session {
cmd.push_option(T_LOWERCASE_KEY, target_session);
}
#[cfg(feature = "tmux_1_7")]
if let Some(variable) = self.variable {
cmd.push_param(variable);
}
cmd
}
}