When working with std::process::Command
, I usually create a function that set shared environment variables and arguments.
I wish to do this:
fn clone_my_repo() -> Command {
Command::new("git")
.env_remove("GIT_DIR")
.arg("clone")
.arg("--depth=1")
.arg("repo url")
}
but couldn't because env_remove
and arg
take and return a mutable reference.
I know I could assign Command::new("git")
to a temporary mutable variable, modify, and return it, but that's verbose.
I can make a trait or a wrapper type with ideal APIs, but I don't want to reinvent the wheel, so let me know if there's already a crate for that.