tmux_interface/commands/miscellaneous/
wait_for.rs1use crate::commands::constants::*;
2use crate::TmuxCommand;
3use std::borrow::Cow;
4
5pub type Wait<'a> = WaitFor<'a>;
6
7#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
23pub struct WaitFor<'a> {
24 #[cfg(feature = "tmux_1_8")]
26 pub locked: bool,
27
28 #[cfg(feature = "tmux_1_8")]
30 pub woken: bool,
31
32 #[cfg(feature = "tmux_1_8")]
34 pub unlocked: bool,
35
36 #[cfg(feature = "tmux_1_8")]
38 pub channel: Option<Cow<'a, str>>,
39}
40
41impl<'a> WaitFor<'a> {
42 pub fn new() -> Self {
43 Default::default()
44 }
45
46 #[cfg(feature = "tmux_1_8")]
48 pub fn locked(mut self) -> Self {
49 self.locked = true;
50 self
51 }
52
53 #[cfg(feature = "tmux_1_8")]
55 pub fn woken(mut self) -> Self {
56 self.woken = true;
57 self
58 }
59
60 #[cfg(feature = "tmux_1_8")]
62 pub fn unlocked(mut self) -> Self {
63 self.unlocked = true;
64 self
65 }
66
67 #[cfg(feature = "tmux_1_8")]
69 pub fn channel<S: Into<Cow<'a, str>>>(mut self, channel: S) -> Self {
70 self.channel = Some(channel.into());
71 self
72 }
73
74 pub fn build(self) -> TmuxCommand<'a> {
75 let mut cmd = TmuxCommand::new();
76
77 cmd.name(WAIT_FOR);
78
79 #[cfg(feature = "tmux_1_8")]
81 if self.locked {
82 cmd.push_flag(L_UPPERCASE_KEY);
83 }
84
85 #[cfg(feature = "tmux_1_8")]
87 if self.woken {
88 cmd.push_flag(S_UPPERCASE_KEY);
89 }
90
91 #[cfg(feature = "tmux_1_8")]
93 if self.unlocked {
94 cmd.push_flag(U_UPPERCASE_KEY);
95 }
96
97 #[cfg(feature = "tmux_1_8")]
99 if let Some(channel) = self.channel {
100 cmd.push_param(channel);
101 }
102 cmd
103 }
104}