#[macro_export]
macro_rules! show_options {
(@cmd ($cmd:expr) -A, $($tail:tt)*) => {{
$crate::show_options!(@cmd ({
$cmd.include_inherited()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -g, $($tail:tt)*) => {{
$crate::show_options!(@cmd ({
$cmd.global()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -H, $($tail:tt)*) => {{
$crate::show_options!(@cmd ({
$cmd.hooks()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -p, $($tail:tt)*) => {{
$crate::show_options!(@cmd ({
$cmd.pane()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -q, $($tail:tt)*) => {{
$crate::show_options!(@cmd ({
$cmd.quiet()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -s, $($tail:tt)*) => {{
$crate::show_options!(@cmd ({
$cmd.server()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -v, $($tail:tt)*) => {{
$crate::show_options!(@cmd ({
$cmd.value()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -w, $($tail:tt)*) => {{
$crate::show_options!(@cmd ({
$cmd.window()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -t $target:expr, $($tail:tt)*) => {{
$crate::show_options!(@cmd ({
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_3_0a")))]
{
$cmd.target_session($target)
}
#[cfg(feature = "tmux_3_0a")]
{
$cmd.target_pane($target)
}
}) $($tail)*)
}};
(@cmd ($cmd:expr) $option:expr, $($tail:tt)*) => {{
$crate::show_options!(@cmd ({
$cmd.option($option)
}) $($tail)*)
}};
(@cmd ($cmd:expr)) => {{
$cmd
}};
() => {{
$crate::ShowOptions::new()
}};
(($cmd:expr), $($tail:tt)*) => {{
$crate::show_options!(@cmd ($cmd) $($tail)*,)
}};
($($tail:tt)*) => {{
$crate::show_options!(@cmd ({ $crate::ShowOptions::new() }) $($tail)*,)
}};
}
#[test]
fn show_options_macro() {
use std::borrow::Cow;
let show_options = show_options!();
#[cfg(feature = "tmux_3_0a")]
let show_options = show_options!((show_options), -A);
#[cfg(feature = "tmux_1_5")]
let show_options = show_options!((show_options), -g);
#[cfg(feature = "tmux_3_0a")]
let show_options = show_options!((show_options), -H);
#[cfg(feature = "tmux_3_0a")]
let show_options = show_options!((show_options), -p);
#[cfg(feature = "tmux_1_8")]
let show_options = show_options!((show_options), -q);
#[cfg(feature = "tmux_1_5")]
let show_options = show_options!((show_options), -s);
#[cfg(feature = "tmux_1_8")]
let show_options = show_options!((show_options), -v);
#[cfg(feature = "tmux_1_5")]
let show_options = show_options!((show_options), -w);
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_3_0a")))]
let show_options = show_options!((show_options), -t "1");
#[cfg(feature = "tmux_3_0a")]
let show_options = show_options!((show_options), -t "2");
#[cfg(feature = "tmux_0_8")]
let show_options = show_options!((show_options), "3");
#[cfg(not(feature = "cmd_alias"))]
let cmd = "show-options";
#[cfg(feature = "cmd_alias")]
let cmd = "show";
let mut s = Vec::new();
s.push(cmd);
#[cfg(feature = "tmux_3_0a")]
s.push("-A");
#[cfg(feature = "tmux_1_5")]
s.push("-g");
#[cfg(feature = "tmux_3_0a")]
s.push("-H");
#[cfg(feature = "tmux_3_0a")]
s.push("-p");
#[cfg(feature = "tmux_1_8")]
s.push("-q");
#[cfg(feature = "tmux_1_5")]
s.push("-s");
#[cfg(feature = "tmux_1_8")]
s.push("-v");
#[cfg(feature = "tmux_1_5")]
s.push("-w");
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_3_0a")))]
s.extend_from_slice(&["-t", "1"]);
#[cfg(feature = "tmux_3_0a")]
s.extend_from_slice(&["-t", "2"]);
#[cfg(feature = "tmux_0_8")]
s.push("3");
let s: Vec<Cow<str>> = s.into_iter().map(|a| a.into()).collect();
let show_options = show_options.build().to_vec();
assert_eq!(show_options, s);
}