use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
pub type LsK<'a> = ListKeys<'a>;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct ListKeys<'a> {
#[cfg(feature = "tmux_3_1")]
pub first: bool,
#[cfg(feature = "tmux_3_1a")]
pub command: bool,
#[cfg(feature = "tmux_3_1")]
pub with_notes: bool,
#[cfg(feature = "tmux_3_1")]
pub prefix_string: Option<Cow<'a, str>>,
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_2_1")))]
pub key_table: Option<Cow<'a, str>>,
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_2_4")))]
pub mode_table: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_2_1")]
pub key_table: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_3_1")]
pub key: Option<Cow<'a, str>>,
}
impl<'a> ListKeys<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_3_1")]
pub fn first(mut self) -> Self {
self.first = true;
self
}
#[cfg(feature = "tmux_3_1a")]
pub fn command(mut self) -> Self {
self.command = true;
self
}
#[cfg(feature = "tmux_3_1")]
pub fn with_notes(mut self) -> Self {
self.with_notes = true;
self
}
#[cfg(feature = "tmux_3_1")]
pub fn prefix_string<S: Into<Cow<'a, str>>>(mut self, prefix_string: S) -> Self {
self.prefix_string = Some(prefix_string.into());
self
}
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_2_1")))]
pub fn key_table<S: Into<Cow<'a, str>>>(mut self, key_table: S) -> Self {
self.key_table = Some(key_table.into());
self
}
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_2_4")))]
pub fn mode_table<S: Into<Cow<'a, str>>>(mut self, mode_table: S) -> Self {
self.mode_table = Some(mode_table.into());
self
}
#[cfg(feature = "tmux_2_1")]
pub fn key_table<S: Into<Cow<'a, str>>>(mut self, key_table: S) -> Self {
self.key_table = Some(key_table.into());
self
}
#[cfg(feature = "tmux_3_1")]
pub fn key<S: Into<Cow<'a, str>>>(mut self, key: S) -> Self {
self.key = Some(key.into());
self
}
pub fn build(self) -> TmuxCommand<'a> {
let mut cmd = TmuxCommand::new();
cmd.name(LIST_KEYS);
#[cfg(feature = "tmux_3_1")]
if self.first {
cmd.push_flag(_1_KEY);
}
#[cfg(feature = "tmux_3_1a")]
if self.command {
cmd.push_flag(A_LOWERCASE_KEY);
}
#[cfg(feature = "tmux_3_1")]
if self.with_notes {
cmd.push_flag(N_UPPERCASE_KEY);
}
#[cfg(feature = "tmux_3_1")]
if let Some(prefix_string) = self.prefix_string {
cmd.push_option(P_UPPERCASE_KEY, prefix_string);
}
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_2_1")))]
if let Some(key_table) = self.key_table {
cmd.push_option(T_LOWERCASE_KEY, key_table);
}
#[cfg(all(feature = "tmux_2_1", not(feature = "tmux_2_4")))]
if let Some(mode_table) = self.mode_table {
cmd.push_option(T_LOWERCASE_KEY, mode_table);
}
#[cfg(feature = "tmux_2_1")]
if let Some(key_table) = self.key_table {
cmd.push_option(T_UPPERCASE_KEY, key_table);
}
#[cfg(feature = "tmux_3_1")]
if let Some(key) = self.key {
cmd.push_param(key);
}
cmd
}
}