printable_shell_command/
shell_printable.rs

1use std::str::Utf8Error;
2
3pub trait ShellPrintable {
4    fn printable_invocation_string(&self) -> Result<String, Utf8Error>;
5    // Calls `.to_string_lossy()` on the program name and args.
6    fn printable_invocation_string_lossy(&self) -> String;
7
8    // Print the invocation to `stdout`.`
9    fn print_invocation(&mut self) -> Result<&mut Self, Utf8Error> {
10        println!("{}", self.printable_invocation_string_lossy());
11        Ok(self)
12    }
13    // Print the invocation to `stdout`.`
14    fn print_invocation_lossy(&mut self) -> &mut Self {
15        println!("{}", self.printable_invocation_string_lossy());
16        self
17    }
18}