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
// auto-generated file
//
/// Remove and free the history for the specified pane.
///
/// # Manual
///
/// tmux ^3.4:
/// ```text
/// clear-history [-H] [-t target-pane]
/// (alias: clearhist)
/// ```
///
/// tmux ^1.5:
/// ```text
/// clear-history [-t target-pane]
/// (alias: clearhist)
/// ```
#[macro_export]
macro_rules! clear_history {
// `[-H]`
(@cmd ($cmd:expr) -H, $($tail:tt)*) => {{
$crate::clear_history!(@cmd ({
$cmd.no_hyperlinks()
}) $($tail)*)
}};
// `[-t target-pane]`
(@cmd ($cmd:expr) -t $target_pane:expr, $($tail:tt)*) => {{
$crate::clear_history!(@cmd ({
$cmd.target_pane($target_pane)
}) $($tail)*)
}};
//(@cmd ($cmd:expr) -$unknown:tt, $($tail:tt)*) => {{
//::std::compile_error!("unknown flag, option or parameter: {}", $unknown);
//}};
(@cmd ($cmd:expr)) => {{
$cmd
}};
() => {{
$crate::ClearHistory::new()
}};
(($cmd:expr), $($tail:tt)*) => {{
$crate::clear_history!(@cmd ($cmd) $($tail)*,)
}};
($($tail:tt)*) => {{
$crate::clear_history!(@cmd ({ $crate::ClearHistory::new() }) $($tail)*,)
}};
}
#[test]
fn clear_history_macro() {
use std::borrow::Cow;
// Remove and free the history for the specified pane.
//
// # Manual
//
// tmux ^3.4:
// ```text
// clear-history [-H] [-t target-pane]
// (alias: clearhist)
// ```
//
// tmux ^1.5:
// ```text
// clear-history [-t target-pane]
// (alias: clearhist)
// ```
let clear_history = clear_history!();
#[cfg(feature = "tmux_3_4")]
let clear_history = clear_history!((clear_history), -H);
#[cfg(feature = "tmux_1_5")]
let clear_history = clear_history!((clear_history), -t "1");
#[cfg(not(feature = "cmd_alias"))]
let cmd = "clear-history";
#[cfg(feature = "cmd_alias")]
let cmd = "clearhist";
let mut s = Vec::new();
s.push(cmd);
#[cfg(feature = "tmux_3_4")]
s.push("-H");
#[cfg(feature = "tmux_1_5")]
s.extend_from_slice(&["-t", "1"]);
let s: Vec<Cow<str>> = s.into_iter().map(|a| a.into()).collect();
let clear_history = clear_history.build().to_vec();
assert_eq!(clear_history, s);
}