- 
                Notifications
    
You must be signed in to change notification settings  - Fork 45
 
Open
Labels
enhancementImprove the expectedImprove the expected
Description
I'm trying to convert some tests to use rexpect::spawn to work around some issues with tty handling, but I'm having trouble re-using all my existing assert_cmd as I can't construct a single string with the constructed command as the cmd field on Command is private.
With the following code
let mut cmd = Command::cargo_bin("my-cmd").unwrap();
cmd.current_dir("/tmp")
  .arg("--foo")
  .arg("bar")
  .env("FOO", "BAR");I'd like to be able to get a string like
cd /tmp && FOO="BAR" ~the-cargo-path/target/debug/my-cmd --foo bar
Calling format!("{:?}", cmd) prints the following, with cmd in the format I'd like, but also stdin/stdout etc
Command { cmd: cd \"/tmp\" && FOO=\"BAR\" \"~the-cargo-path/target/debug/my-cmd\" \"--foo\" \"bar\", stdin: None, timeout: None }
I'm not sure what the most rust-y solution would be, but it would help if either:
cmdwas marked public- a method was added to get 
cmdin a serialized form - a method was added to 
Commandto get the underlying cmd, at which point I think I can serialize it myself 
I'm happy to attempt a PR if an option from the above is chosen / another suggested
Metadata
Metadata
Assignees
Labels
enhancementImprove the expectedImprove the expected