(&self)
| 94 | } |
| 95 | |
| 96 | fn pre_run_output(&self) { |
| 97 | match self.verbosity { |
| 98 | CmdVerbosity::Quiet => {} |
| 99 | CmdVerbosity::Description => { |
| 100 | println!("{}", self.description); |
| 101 | } |
| 102 | CmdVerbosity::Verbose => { |
| 103 | // Output the description first |
| 104 | println!("{}", self.description); |
| 105 | |
| 106 | // Lock stdout so we buffer |
| 107 | let mut stdout = std::io::stdout().lock(); |
| 108 | let cmd_args = std::iter::once(self.cmd.get_program()) |
| 109 | .chain(self.cmd.get_args()) |
| 110 | .map(|arg| arg.to_string_lossy()); |
| 111 | // We unwrap() here to match the default for println!() even though |
| 112 | // arguably that's wrong |
| 113 | stdout.write_all(b">").unwrap(); |
| 114 | for s in cmd_args { |
| 115 | stdout.write_all(b" ").unwrap(); |
| 116 | stdout.write_all(s.as_bytes()).unwrap(); |
| 117 | } |
| 118 | stdout.write_all(b"\n").unwrap(); |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | /// Run the command with optional stdin buffer, returning an error if the command does not exit successfully. |
| 124 | pub(crate) fn run_with_stdin_buf(self, stdin: Option<&[u8]>) -> Result<()> { |
no outgoing calls
no test coverage detected