tmux_interface/commands/clients_and_sessions/
show_messages.rs1use crate::commands::constants::*;
2use crate::TmuxCommand;
3use std::borrow::Cow;
4
5pub type ShowMsgs<'a> = ShowMessages<'a>;
6
7#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
29pub struct ShowMessages<'a> {
30 #[cfg(all(feature = "tmux_1_9", not(feature = "tmux_2_2")))]
32 pub server: bool,
33 #[cfg(feature = "tmux_1_9")]
35 pub jobs: bool,
36 #[cfg(feature = "tmux_1_9")]
38 pub terminals: bool,
39 #[cfg(feature = "tmux_1_2")]
41 pub target_client: Option<Cow<'a, str>>,
42}
43
44impl<'a> ShowMessages<'a> {
45 pub fn new() -> Self {
46 Default::default()
47 }
48
49 #[cfg(all(feature = "tmux_1_9", not(feature = "tmux_2_2")))]
51 pub fn server(mut self) -> Self {
52 self.server = true;
53 self
54 }
55
56 #[cfg(feature = "tmux_1_9")]
58 pub fn jobs(mut self) -> Self {
59 self.jobs = true;
60 self
61 }
62
63 #[cfg(feature = "tmux_1_9")]
65 pub fn terminals(mut self) -> Self {
66 self.terminals = true;
67 self
68 }
69
70 #[cfg(feature = "tmux_1_2")]
72 pub fn target_client<S: Into<Cow<'a, str>>>(mut self, target_client: S) -> Self {
73 self.target_client = Some(target_client.into());
74 self
75 }
76
77 pub fn build(self) -> TmuxCommand<'a> {
78 let mut cmd = TmuxCommand::new();
79
80 cmd.name(SHOW_MESSAGES);
81
82 #[cfg(all(feature = "tmux_1_9", not(feature = "tmux_2_2")))]
84 if self.server {
85 cmd.push_flag(I_UPPERCASE_KEY);
86 }
87
88 #[cfg(feature = "tmux_1_9")]
90 if self.jobs {
91 cmd.push_flag(J_UPPERCASE_KEY);
92 }
93
94 #[cfg(feature = "tmux_1_9")]
96 if self.terminals {
97 cmd.push_flag(T_UPPERCASE_KEY);
98 }
99
100 #[cfg(feature = "tmux_1_2")]
102 if let Some(target_client) = self.target_client {
103 cmd.push_option(T_LOWERCASE_KEY, target_client);
104 }
105
106 cmd
107 }
108}