1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
/// Put a pane into client mode, allowing a client to be selected interactively from a list
///
/// # Manual
///
/// tmux ^3.2:
/// ```text
/// choose-client [-NrZ] [-F format] [-f filter] [-K key-format] [-O sort-order] [-t target-pane] [template]
/// ```
///
/// tmux ^3.1:
/// ```text
/// choose-client [-NrZ] [-F format] [-f filter] [-O sort-order] [-t target-pane] [template]
/// ```
///
/// tmux ^2.7:
/// ```text
/// choose-client [-NZ] [-F format] [-f filter] [-O sort-order] [-t target-pane] [template]
/// ```
///
/// tmux ^2.6:
/// ```text
/// choose-client [-N] [-F format] [-f filter] [-O sort-order] [-t target-pane] [template]
/// ```
///
/// tmux ^1.7:
/// ```text
/// choose-client [-F format] [-t target-window] [template]
/// ```
///
/// tmux ^1.0:
/// ```text
/// choose-client [-t target-window] [template]
/// ```
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct ChooseClient<'a> {
/// `[-N]` - start without the preview
#[cfg(feature = "tmux_2_6")]
pub without_preview: bool,
/// `[-r]` - reverse the sort order
#[cfg(feature = "tmux_3_1")]
pub reverse_sort_order: bool,
/// `[-Z]` - zoom the pane
#[cfg(feature = "tmux_3_1")]
pub zoom: bool,
/// `[-F format]` - format
#[cfg(feature = "tmux_1_7")]
pub format: Option<Cow<'a, str>>,
/// `[-f filter]` - specify an initial filter
#[cfg(feature = "tmux_2_6")]
pub filter: Option<Cow<'a, str>>,
/// `[-K key-format]` - format for each shortcut key
#[cfg(feature = "tmux_3_2")]
pub key_format: Option<Cow<'a, str>>,
// XXX: type?
/// `[-O sort-order]` - specify the initial sort field
#[cfg(feature = "tmux_2_6")]
pub sort_order: Option<Cow<'a, str>>,
/// `[-t target-pane]` - target-pane
#[cfg(feature = "tmux_2_6")]
pub target_pane: Option<Cow<'a, str>>,
/// `[-t target-window]` - target-window
#[cfg(all(feature = "tmux_1_0", not(feature = "tmux_2_6")))]
pub target_window: Option<Cow<'a, str>>,
/// `[template]` - template
#[cfg(feature = "tmux_1_0")]
pub template: Option<Cow<'a, str>>,
}
impl<'a> ChooseClient<'a> {
pub fn new() -> Self {
Default::default()
}
/// `[-N]` - start without the preview
#[cfg(feature = "tmux_2_6")]
pub fn without_preview(mut self) -> Self {
self.without_preview = true;
self
}
/// `[-r]` - reverse the sort order
#[cfg(feature = "tmux_3_1")]
pub fn reverse_sort_order(mut self) -> Self {
self.reverse_sort_order = true;
self
}
/// `[-Z]` - zoom the pane
#[cfg(feature = "tmux_3_1")]
pub fn zoom(mut self) -> Self {
self.zoom = true;
self
}
/// `[-F format]` - format
#[cfg(feature = "tmux_1_7")]
pub fn format<S: Into<Cow<'a, str>>>(mut self, format: S) -> Self {
self.format = Some(format.into());
self
}
/// `[-f filter]` - specify an initial filter
#[cfg(feature = "tmux_2_6")]
pub fn filter<S: Into<Cow<'a, str>>>(mut self, filter: S) -> Self {
self.filter = Some(filter.into());
self
}
/// `[-K key-format]` - format for each shortcut key
#[cfg(feature = "tmux_3_2")]
pub fn key_format<S: Into<Cow<'a, str>>>(mut self, key_format: S) -> Self {
self.key_format = Some(key_format.into());
self
}
/// `[-O sort-order]` - specify the initial sort field
#[cfg(feature = "tmux_2_6")]
pub fn sort_order<S: Into<Cow<'a, str>>>(mut self, sort_order: S) -> Self {
self.sort_order = Some(sort_order.into());
self
}
/// `[-t target-pane]` - target-pane
#[cfg(feature = "tmux_2_6")]
pub fn target_pane<S: Into<Cow<'a, str>>>(mut self, target_pane: S) -> Self {
self.target_pane = Some(target_pane.into());
self
}
/// `[-t target-window]` - target-window
#[cfg(all(feature = "tmux_1_0", not(feature = "tmux_2_6")))]
pub fn target_window<S: Into<Cow<'a, str>>>(mut self, target_window: S) -> Self {
self.target_window = Some(target_window.into());
self
}
/// `[template]` - template
#[cfg(feature = "tmux_1_0")]
pub fn template<S: Into<Cow<'a, str>>>(mut self, template: S) -> Self {
self.template = Some(template.into());
self
}
pub fn build(self) -> TmuxCommand<'a> {
let mut cmd = TmuxCommand::new();
cmd.name(CHOOSE_CLIENT);
// `[-N]` - start without the preview
#[cfg(feature = "tmux_2_6")]
if self.without_preview {
cmd.push_flag(N_UPPERCASE_KEY);
}
// `[-r]` - reverse the sort order
#[cfg(feature = "tmux_3_1")]
if self.reverse_sort_order {
cmd.push_flag(R_LOWERCASE_KEY);
}
// `[-Z]` - zoom the pane
#[cfg(feature = "tmux_3_1")]
if self.zoom {
cmd.push_flag(Z_UPPERCASE_KEY);
}
// `[-F format]` - format
#[cfg(feature = "tmux_1_7")]
if let Some(format) = self.format {
cmd.push_option(F_UPPERCASE_KEY, format);
}
// `[-f filter]` - specify an initial filter
#[cfg(feature = "tmux_2_6")]
if let Some(filter) = self.filter {
cmd.push_option(F_LOWERCASE_KEY, filter);
}
// `[-K key-format]` - format for each shortcut key
#[cfg(feature = "tmux_3_2")]
if let Some(key_format) = self.key_format {
cmd.push_option(K_UPPERCASE_KEY, key_format);
}
// `[-O sort-order]` - specify the initial sort field
#[cfg(feature = "tmux_2_6")]
if let Some(sort_order) = self.sort_order {
cmd.push_option(O_UPPERCASE_KEY, sort_order);
}
// `[-t target-pane]` - target-pane
#[cfg(feature = "tmux_2_6")]
if let Some(target_pane) = self.target_pane {
cmd.push_option(T_LOWERCASE_KEY, target_pane);
}
// `[-t target-window]` - target-window
#[cfg(all(feature = "tmux_1_0", not(feature = "tmux_2_6")))]
if let Some(target_window) = self.target_window {
cmd.push_option(T_LOWERCASE_KEY, target_window);
}
// `[template]` - template
#[cfg(feature = "tmux_1_0")]
if let Some(template) = self.template {
cmd.push_param(template);
}
cmd
}
}