tmux_interface/commands/buffers/
delete_buffer.rs1use crate::commands::constants::*;
5use crate::TmuxCommand;
6use std::borrow::Cow;
7
8pub type DeleteB<'a> = DeleteBuffer<'a>;
9
10#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
33pub struct DeleteBuffer<'a> {
34 #[cfg(all(feature = "tmux_0_8", not(feature = "tmux_2_0")))]
36 pub buffer_index: Option<Cow<'a, str>>,
37
38 #[cfg(feature = "tmux_2_0")]
40 pub buffer_name: Option<Cow<'a, str>>,
41
42 #[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
44 pub target_session: Option<Cow<'a, str>>,
45}
46
47impl<'a> DeleteBuffer<'a> {
48 pub fn new() -> Self {
49 Default::default()
50 }
51
52 #[cfg(all(feature = "tmux_0_8", not(feature = "tmux_2_0")))]
54 pub fn buffer_index<S: Into<Cow<'a, str>>>(mut self, buffer_index: S) -> Self {
55 self.buffer_index = Some(buffer_index.into());
56 self
57 }
58
59 #[cfg(feature = "tmux_2_0")]
61 pub fn buffer_name<S: Into<Cow<'a, str>>>(mut self, buffer_name: S) -> Self {
62 self.buffer_name = Some(buffer_name.into());
63 self
64 }
65
66 #[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
68 pub fn target_session<S: Into<Cow<'a, str>>>(mut self, target_session: S) -> Self {
69 self.target_session = Some(target_session.into());
70 self
71 }
72
73 pub fn build(self) -> TmuxCommand<'a> {
75 let mut cmd = TmuxCommand::new();
76
77 cmd.name(DELETE_BUFFER);
78
79 #[cfg(all(feature = "tmux_0_8", not(feature = "tmux_2_0")))]
81 if let Some(buffer_index) = self.buffer_index {
82 cmd.push_option(B_LOWERCASE_KEY, buffer_index);
83 }
84
85 #[cfg(feature = "tmux_2_0")]
87 if let Some(buffer_name) = self.buffer_name {
88 cmd.push_option(B_LOWERCASE_KEY, buffer_name);
89 }
90
91 #[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
93 if let Some(target_session) = self.target_session {
94 cmd.push_option(T_LOWERCASE_KEY, target_session);
95 }
96
97 cmd
98 }
99}