#[macro_export]
macro_rules! set_window_option {
(@cmd ($cmd:expr) -a, $($tail:tt)*) => {{
$crate::set_window_option!(@cmd ({
$cmd.append()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -F, $($tail:tt)*) => {{
$crate::set_window_option!(@cmd ({
$cmd.format()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -g, $($tail:tt)*) => {{
$crate::set_window_option!(@cmd ({
$cmd.global()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -o, $($tail:tt)*) => {{
$crate::set_window_option!(@cmd ({
$cmd.not_overwrite()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -q, $($tail:tt)*) => {{
$crate::set_window_option!(@cmd ({
$cmd.quiet()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -u, $($tail:tt)*) => {{
$crate::set_window_option!(@cmd ({
$cmd.unset()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -t $target_window:expr, $($tail:tt)*) => {{
$crate::set_window_option!(@cmd ({
$cmd.target_window($target_window)
}) $($tail)*)
}};
(@cmd ($cmd:expr) $option:expr, $($tail:tt)*) => {{
$crate::set_window_option!(@cmd ({
$cmd.option($option)
}) $($tail)*)
}};
(@cmd ($cmd:expr) --value $value:expr, $($tail:tt)*) => {{
$crate::set_window_option!(@cmd ({
$cmd.value($value)
}) $($tail)*)
}};
(@cmd ($cmd:expr)) => {{
$cmd
}};
() => {{
$crate::SetWindowOption::new()
}};
(($cmd:expr), $($tail:tt)*) => {{
$crate::set_window_option!(@cmd ($cmd) $($tail)*,)
}};
($($tail:tt)*) => {{
$crate::set_window_option!(@cmd ({ $crate::SetWindowOption::new() }) $($tail)*,)
}};
}
#[test]
fn set_window_option_macro() {
use std::borrow::Cow;
let set_window_option = set_window_option!();
#[cfg(feature = "tmux_1_5")]
let set_window_option = set_window_option!((set_window_option), -a);
#[cfg(feature = "tmux_2_6")]
let set_window_option = set_window_option!((set_window_option), -F);
#[cfg(feature = "tmux_0_8")]
let set_window_option = set_window_option!((set_window_option), -g);
#[cfg(feature = "tmux_1_9")]
let set_window_option = set_window_option!((set_window_option), -o);
#[cfg(feature = "tmux_1_7")]
let set_window_option = set_window_option!((set_window_option), -q);
#[cfg(feature = "tmux_0_8")]
let set_window_option = set_window_option!((set_window_option), -u);
#[cfg(feature = "tmux_0_8")]
let set_window_option = set_window_option!((set_window_option), -t "1");
#[cfg(feature = "tmux_0_8")]
let set_window_option = set_window_option!((set_window_option), "2");
#[cfg(feature = "tmux_0_8")]
let set_window_option = set_window_option!((set_window_option), --value "3");
#[cfg(not(feature = "cmd_alias"))]
let cmd = "set-window-option";
#[cfg(feature = "cmd_alias")]
let cmd = "setw";
let mut s = Vec::new();
s.push(cmd);
#[cfg(feature = "tmux_1_5")]
s.push("-a");
#[cfg(feature = "tmux_2_6")]
s.push("-F");
#[cfg(feature = "tmux_0_8")]
s.push("-g");
#[cfg(feature = "tmux_1_9")]
s.push("-o");
#[cfg(feature = "tmux_1_7")]
s.push("-q");
#[cfg(feature = "tmux_0_8")]
s.push("-u");
#[cfg(feature = "tmux_0_8")]
s.extend_from_slice(&["-t", "1"]);
#[cfg(feature = "tmux_0_8")]
s.push("2");
#[cfg(feature = "tmux_0_8")]
s.push("3");
let s: Vec<Cow<str>> = s.into_iter().map(|a| a.into()).collect();
let set_window_option = set_window_option.build().to_vec();
assert_eq!(set_window_option, s);
}