feat: Add the ability to set current dir and env vars
This commit is contained in:
51
src/lib.rs
51
src/lib.rs
@@ -28,6 +28,57 @@ mod cmd;
|
||||
/// assert_eq!(format!("{command:?}"), r#""echo" "test""#.to_string());
|
||||
/// ```
|
||||
///
|
||||
/// ## Current Directory
|
||||
/// ```
|
||||
/// use comlexr::cmd;
|
||||
///
|
||||
/// let command = cmd!(
|
||||
/// cd "~/";
|
||||
/// "echo",
|
||||
/// "test",
|
||||
/// );
|
||||
///
|
||||
/// assert_eq!(format!("{command:?}"), r#"cd "~/" && "echo" "test""#);
|
||||
/// ```
|
||||
///
|
||||
/// ## Environment Vars
|
||||
/// ```
|
||||
/// use comlexr::cmd;
|
||||
///
|
||||
/// const NEW_VAR: &str = "NEW_VAR";
|
||||
///
|
||||
/// let command = cmd!(
|
||||
/// env {
|
||||
/// "TEST": "test",
|
||||
/// NEW_VAR: "new_var"
|
||||
/// };
|
||||
/// "echo",
|
||||
/// "test",
|
||||
/// );
|
||||
///
|
||||
/// assert_eq!(format!("{command:?}"), r#"NEW_VAR="new_var" TEST="test" "echo" "test""#);
|
||||
/// ```
|
||||
///
|
||||
/// ### Current Directory and Environment Variable Order
|
||||
/// ```
|
||||
/// use comlexr::cmd;
|
||||
///
|
||||
/// let command = cmd!(
|
||||
/// cd "~/";
|
||||
/// env {
|
||||
/// "TEST": "test",
|
||||
/// };
|
||||
/// "echo",
|
||||
/// "test",
|
||||
/// );
|
||||
///
|
||||
/// assert_eq!(
|
||||
/// format!("{command:?}"),
|
||||
/// r#"cd "~/" && TEST="test" "echo" "test""#
|
||||
/// );
|
||||
///
|
||||
/// ```
|
||||
///
|
||||
/// ## Conditional Arguments
|
||||
/// ```
|
||||
/// use comlexr::cmd;
|
||||
|
||||
Reference in New Issue
Block a user