dukit 0.4.2

git cli tool for the feathered
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::SWITCHED_BRANCH;
use std::process::Output;

#[derive(Debug)]
pub struct DisplayableCliCommand(pub Output);

impl std::fmt::Display for DisplayableCliCommand {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let stdout = String::from_utf8_lossy(&self.0.stdout);
        let stderr = String::from_utf8_lossy(&self.0.stderr);

        if stderr.is_empty() && !stderr.contains(SWITCHED_BRANCH) {
            return writeln!(f, "{}", stdout);
        }
        writeln!(f, "{}", stderr)
    }
}