#[doc = crate::_tags!(code platform runtime)]
#[doc = crate::_doc_meta!{location("work/process")}]
#[macro_export]
#[cfg_attr(cargo_primary_package, doc(hidden))]
macro_rules! cmd {
(@ $cmd:literal $(,)?) => {{
$crate::CommandFlow::new($crate::cmd!(%cmd @ $cmd))
}};
(@ $first:literal => $($rest:tt)+) => {{
let flow = $crate::CommandFlow::new($crate::cmd!(%cmd @ $first));
$crate::cmd!(%flow flow => $($rest)+)
}};
($($first:expr),+ => $($rest:tt)+) => {{
let flow = $crate::CommandFlow::new($crate::cmd!(%cmd $($first),+));
$crate::cmd!(%flow flow => $($rest)+)
}};
($($args:expr),+ $(,)?) => {{
$crate::CommandFlow::new($crate::cmd!(%cmd $($args),+))
}};
() => { compile_error!("`cmd!` needs at least one command") };
(%flow $flow:expr => @ $next:literal => $($rest:tt)+) => {{
let flow = $flow.then($crate::cmd!(%cmd @ $next));
$crate::cmd!(%flow flow => $($rest)+)
}};
(%flow $flow:expr => @ $next:literal $(,)?) => {{
$flow.then($crate::cmd!(%cmd @ $next))
}};
(%flow $flow:expr => $($next:expr),+ => $($rest:tt)+) => {{
let flow = $flow.then($crate::cmd!(%cmd $($next),+));
$crate::cmd!(%flow flow => $($rest)+)
}};
(%flow $flow:expr => $($next:expr),+ $(,)?) => {{
$flow.then($crate::cmd!(%cmd $($next),+))
}};
(%cmd @ $cmd:literal) => {{
$crate::__cmd_shell!($cmd)
}};
(%cmd $prog:expr $(, $arg:expr)* $(,)?) => {{
let mut command = $crate::Command::new($prog);
$(command.arg($arg);)*
command
}};
}
#[doc(inline)]
pub use cmd;
#[cfg(feature = "shell")]
#[doc(hidden)]
#[macro_export]
macro_rules! __cmd_shell {
($cmd:literal) => {{
use $crate::ProcessExt as _;
$crate::Process::command_shell($cmd).expect("invalid command literal")
}};
}
#[cfg(not(feature = "shell"))]
#[doc(hidden)]
#[macro_export]
macro_rules! __cmd_shell {
($cmd:literal) => {{ compile_error!("`cmd!(@ \"...\")` requires devela's `shell` feature") }};
}
#[doc(hidden)]
pub use __cmd_shell;