#[macro_export]
macro_rules! kill_pane {
(@cmd ($cmd:expr) -a, $($tail:tt)*) => {{
$crate::kill_pane!(@cmd ({
$cmd.all()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -t $target:expr, $($tail:tt)*) => {{
$crate::kill_pane!(@cmd ({
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
{
$cmd.target_window($target)
}
#[cfg(feature = "tmux_1_5")]
{
$cmd.target_pane($target)
}
}) $($tail)*)
}};
(@cmd ($cmd:expr)) => {{
$cmd
}};
() => {{
$crate::KillPane::new()
}};
(($cmd:expr), $($tail:tt)*) => {{
$crate::kill_pane!(@cmd ($cmd) $($tail)*,)
}};
($($tail:tt)*) => {{
$crate::kill_pane!(@cmd ({ $crate::KillPane::new() }) $($tail)*,)
}};
}
#[test]
fn kill_pane_macro() {
use std::borrow::Cow;
let kill_pane = kill_pane!();
#[cfg(feature = "tmux_1_5")]
let kill_pane = kill_pane!((kill_pane), -a);
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
let kill_pane = kill_pane!((kill_pane), -t "1");
#[cfg(feature = "tmux_1_5")]
let kill_pane = kill_pane!((kill_pane), -t "2");
#[cfg(not(feature = "cmd_alias"))]
let cmd = "kill-pane";
#[cfg(feature = "cmd_alias")]
let cmd = "killp";
let mut s = Vec::new();
s.push(cmd);
#[cfg(feature = "tmux_1_5")]
s.push("-a");
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
s.extend_from_slice(&["-t", "1"]);
#[cfg(feature = "tmux_1_5")]
s.extend_from_slice(&["-t", "2"]);
let s: Vec<Cow<str>> = s.into_iter().map(|a| a.into()).collect();
let kill_pane = kill_pane.build().to_vec();
assert_eq!(kill_pane, s);
}