Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,16 @@ impl Cmd {
})
}

fn to_command(&self) -> Command {
/// Constructs a [`std::process::Command`] for the same command as `self`.
///
/// The returned command will invoke the same program from the same working
/// directory and with the same environment as `self`. If the command was
/// set to [`ignore_stdout`](Cmd::ignore_stdout) or [`ignore_stderr`](Cmd::ignore_stderr),
/// this will apply to the returned command as well.
///
/// Other builder methods have no effect on the command returned since they
/// control how the command is run, but this method does not yet execute the command.
pub fn to_command(&self) -> Command {
let mut result = Command::new(&self.prog);
result.current_dir(&self.sh.cwd);
result.args(&self.args);
Expand Down
4 changes: 3 additions & 1 deletion tests/it/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ fn smoke() {
#[test]
fn into_command() {
let sh = setup();
let _: std::process::Command = cmd!(sh, "git branch").into();
let cmd = cmd!(sh, "git branch");
let _ = cmd.to_command();
let _: std::process::Command = cmd.into();
}

#[test]
Expand Down
Loading