#[macro_export]
macro_rules! kill_pane {
(@cmd ($cmd:expr) -a, $($tail:tt)*) => {{
$crate::kill_pane!(@cmd ({
$cmd.all()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -t $target_pane:expr, $($tail:tt)*) => {{
$crate::kill_pane!(@cmd ({
$cmd.target_pane($target_pane)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -p $pane_index:expr, $($tail:tt)*) => {{
$crate::kill_pane!(@cmd ({
$cmd.pane_index($pane_index)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -t $target_window:expr, $($tail:tt)*) => {{
$crate::kill_pane!(@cmd ({
$cmd.target_window($target_window)
}) $($tail)*)
}};
(@cmd ($cmd:expr) $shell_command:expr, $($tail:tt)*) => {{
$crate::kill_pane!(@cmd ({
$cmd.shell_command($shell_command)
}) $($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 crate::TargetPane;
use std::borrow::Cow;
let target_pane = TargetPane::Raw("1").to_string();
let kill_pane = kill_pane!();
#[cfg(feature = "tmux_1_1")]
let kill_pane = kill_pane!((kill_pane), -a);
#[cfg(feature = "tmux_1_0")]
let kill_pane = kill_pane!((kill_pane), -t & target_pane);
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_0")))]
let kill_pane = kill_pane!((kill_pane), -p "2");
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_0")))]
let kill_pane = kill_pane!((kill_pane), -t "3");
#[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_1")]
s.push("-a");
#[cfg(feature = "tmux_0_8")]
s.extend_from_slice(&["-t", "1"]);
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_0")))]
s.extend_from_slice(&["-p", "2"]);
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_0")))]
s.extend_from_slice(&["-t", "3"]);
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);
}