use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
use std::marker::PhantomData;
pub type LsCm<'a> = ListCommands<'a>;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct ListCommands<'a> {
#[cfg(feature = "tmux_2_3")]
pub format: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_3_1a")]
pub command: Option<Cow<'a, str>>,
_phantom: PhantomData<&'a str>,
}
impl<'a> ListCommands<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_2_3")]
pub fn format<S: Into<Cow<'a, str>>>(mut self, format: S) -> Self {
self.format = Some(format.into());
self
}
#[cfg(feature = "tmux_3_1a")]
pub fn command<S: Into<Cow<'a, str>>>(mut self, command: S) -> Self {
self.command = Some(command.into());
self
}
pub fn build(self) -> TmuxCommand<'a> {
let mut cmd = TmuxCommand::new();
cmd.name(LIST_COMMANDS);
#[cfg(feature = "tmux_2_3")]
if let Some(format) = self.format {
cmd.push_option(F_UPPERCASE_KEY, format);
}
#[cfg(feature = "tmux_3_1a")]
if let Some(command) = self.command {
cmd.push_param(command);
}
cmd
}
}