#[macro_export]
macro_rules! tmux {
(@cmd ($cmd:expr) -2, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.colours256()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -8, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.colours88()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -d, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.default_colours()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -q, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.prevent_msg()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -C, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.control_mode()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -CC, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.disable_echo()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -D, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.no_daemon()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -h, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.help()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -l, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.login_shell()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -N, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.no_start()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -U, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.unlock()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -u, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.force_utf8()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -v, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.verbose_logging()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -V, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.version()
}) $($tail)*)
}};
(@cmd ($cmd:expr) -c $shell_command:expr, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.shell_command($shell_command)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -f $file:expr, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.file($file)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -L $socket_name:expr, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.socket_name($socket_name)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -S $socket_path:expr, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.socket_path($socket_path)
}) $($tail)*)
}};
(@cmd ($cmd:expr) -T $features:expr, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.features($features)
}) $($tail)*)
}};
(@cmd ($cmd:expr) $command:expr, $($tail:tt)*) => {{
$crate::tmux!(@cmd ({
$cmd.command($command)
}) $($tail)*)
}};
(@cmd ($cmd:expr)) => {{
$cmd
}};
() => {{
$crate::Tmux::new()
}};
(($cmd:expr), $($tail:tt)*) => {{
$crate::tmux!(@cmd ($cmd) $($tail)*,)
}};
($($tail:tt)*) => {{
$crate::tmux!(@cmd ({ $crate::Tmux::new() }) $($tail)*,)
}};
}
#[test]
fn tmux_macro() {
use crate::ListBuffers;
use std::borrow::Cow;
let tmux = tmux!();
#[cfg(feature = "tmux_0_8")]
let tmux = tmux!((tmux), -2);
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_9")))]
let tmux = tmux!((tmux), -8);
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
let tmux = tmux!((tmux), -d);
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_2_1")))]
let tmux = tmux!((tmux), -q);
#[cfg(feature = "tmux_1_8")]
let tmux = tmux!((tmux), -C);
#[cfg(feature = "tmux_1_8")]
let tmux = tmux!((tmux), -CC);
#[cfg(feature = "tmux_3_2")]
let tmux = tmux!((tmux), -D);
#[cfg(feature = "tmux_3_6")]
let tmux = tmux!((tmux), -h);
#[cfg(feature = "tmux_1_5")]
let tmux = tmux!((tmux), -l);
#[cfg(feature = "tmux_3_4")]
let tmux = tmux!((tmux), -N);
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
let tmux = tmux!((tmux), -U);
#[cfg(feature = "tmux_0_8")]
let tmux = tmux!((tmux), -u);
#[cfg(feature = "tmux_0_8")]
let tmux = tmux!((tmux), -v);
#[cfg(feature = "tmux_0_8")]
let tmux = tmux!((tmux), -V);
#[cfg(feature = "tmux_1_5")]
let tmux = tmux!((tmux), -c "1");
#[cfg(feature = "tmux_0_8")]
let tmux = tmux!((tmux), -f "2");
#[cfg(feature = "tmux_0_8")]
let tmux = tmux!((tmux), -L "3");
#[cfg(feature = "tmux_0_8")]
let tmux = tmux!((tmux), -S "4");
#[cfg(feature = "tmux_3_2")]
let tmux = tmux!((tmux), -T "5");
#[cfg(feature = "tmux_0_8")]
let tmux = tmux!((tmux), ListBuffers::new());
let cmd = "tmux";
let mut s = Vec::new();
s.push(cmd);
#[cfg(feature = "tmux_0_8")]
s.push("-2");
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_9")))]
s.push("-8");
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
s.push("-d");
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_2_1")))]
s.push("-q");
#[cfg(feature = "tmux_1_8")]
s.push("-C");
#[cfg(feature = "tmux_1_8")]
s.push("-CC");
#[cfg(feature = "tmux_3_2")]
s.push("-D");
#[cfg(feature = "tmux_3_6")]
s.push("-h");
#[cfg(feature = "tmux_1_5")]
s.push("-l");
#[cfg(feature = "tmux_3_4")]
s.push("-N");
#[cfg(all(feature = "tmux_0_8", not(feature = "tmux_1_5")))]
s.push("-U");
#[cfg(feature = "tmux_0_8")]
s.push("-u");
#[cfg(feature = "tmux_0_8")]
s.push("-v");
#[cfg(feature = "tmux_0_8")]
s.push("-V");
#[cfg(feature = "tmux_1_5")]
s.extend_from_slice(&["-c", "1"]);
#[cfg(feature = "tmux_0_8")]
s.extend_from_slice(&["-f", "2"]);
#[cfg(feature = "tmux_0_8")]
s.extend_from_slice(&["-L", "3"]);
#[cfg(feature = "tmux_0_8")]
s.extend_from_slice(&["-S", "4"]);
#[cfg(feature = "tmux_3_2")]
s.extend_from_slice(&["-T", "5"]);
#[cfg(feature = "tmux_0_8")]
s.push("list-buffers");
let s: Vec<Cow<str>> = s.into_iter().map(|a| a.into()).collect();
let tmux = tmux.build().to_vec();
assert_eq!(tmux, s);
}