Add Show to ProcessBuilder
authorYehuda Katz <wycats@gmail.com>
Fri, 9 May 2014 00:50:10 +0000 (17:50 -0700)
committerYehuda Katz <wycats@gmail.com>
Fri, 9 May 2014 00:50:58 +0000 (17:50 -0700)
src/cargo/util/process_builder.rs

index 4356dcab677d7d685a3605db75f259de7b6f25bf..1740c9a4a8b45fe30b76572af1cc16ee8c7b4244 100644 (file)
@@ -1,3 +1,5 @@
+use std::fmt;
+use std::fmt::{Show,Formatter};
 use std::os;
 use std::path::Path;
 use std::io;
@@ -13,6 +15,18 @@ pub struct ProcessBuilder {
     cwd: Path
 }
 
+impl Show for ProcessBuilder {
+    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+        try!(write!(f.buf, "`{}", self.program));
+
+        if self.args.len() > 0 {
+            try!(write!(f.buf, " {}", self.args.connect(" ")));
+        }
+
+        write!(f.buf, "`")
+    }
+}
+
 // TODO: Upstream a Windows/Posix branch to Rust proper
 static PATH_SEP : &'static str = ":";