cli_assert/
macros.rs

1/// Returns the absolute path to the directory containing Cargo manifest file.
2#[macro_export]
3macro_rules! cargo_manifest_dir {
4  () => {
5    env!("CARGO_MANIFEST_DIR")
6  };
7}
8
9/// Returns the name of the Cargo package.
10#[macro_export]
11macro_rules! cargo_package {
12  () => {
13    env!("CARGO_PKG_NAME")
14  };
15}
16
17/// Returns the absolute path to the target's executable file.
18#[macro_export]
19macro_rules! cargo_binary {
20  () => {
21    $crate::cargo_binary!($crate::cargo_package!())
22  };
23  ($name:expr) => {
24    env!(concat!("CARGO_BIN_EXE_", $name))
25  };
26}
27
28/// Returns a new command-line command.
29#[macro_export]
30macro_rules! command {
31  () => {
32    $crate::Command::new($crate::cargo_binary!(), file!(), $crate::cargo_manifest_dir!())
33  };
34  ($name:expr) => {
35    $crate::Command::new($crate::cargo_binary!($name), file!(), $crate::cargo_manifest_dir!())
36  };
37}