| 
30 | 30 | #![deny(rust_2018_idioms)]  | 
31 | 31 | #![forbid(unsafe_code)]  | 
32 | 32 | 
 
  | 
 | 33 | +use anyhow::bail;  | 
33 | 34 | use std::str::FromStr;  | 
34 | 35 | 
 
  | 
35 | 36 | #[derive(Debug, Eq, PartialEq, Hash, Clone, Copy)]  | 
@@ -82,6 +83,45 @@ pub mod repository;  | 
82 | 83 | mod discover;  | 
83 | 84 | pub use discover::discover;  | 
84 | 85 | 
 
  | 
 | 86 | +pub fn env(mut out: impl std::io::Write, format: OutputFormat) -> anyhow::Result<()> {  | 
 | 87 | +    if format != OutputFormat::Human {  | 
 | 88 | +        bail!("JSON output isn't supported");  | 
 | 89 | +    };  | 
 | 90 | + | 
 | 91 | +    let width = 15;  | 
 | 92 | +    writeln!(  | 
 | 93 | +        out,  | 
 | 94 | +        "{field:>width$}: {}",  | 
 | 95 | +        std::path::Path::new(gix::path::env::shell()).display(),  | 
 | 96 | +        field = "shell",  | 
 | 97 | +    )?;  | 
 | 98 | +    writeln!(  | 
 | 99 | +        out,  | 
 | 100 | +        "{field:>width$}: {:?}",  | 
 | 101 | +        gix::path::env::installation_config_prefix(),  | 
 | 102 | +        field = "config prefix",  | 
 | 103 | +    )?;  | 
 | 104 | +    writeln!(  | 
 | 105 | +        out,  | 
 | 106 | +        "{field:>width$}: {:?}",  | 
 | 107 | +        gix::path::env::installation_config(),  | 
 | 108 | +        field = "config",  | 
 | 109 | +    )?;  | 
 | 110 | +    writeln!(  | 
 | 111 | +        out,  | 
 | 112 | +        "{field:>width$}: {}",  | 
 | 113 | +        gix::path::env::exe_invocation().display(),  | 
 | 114 | +        field = "git exe",  | 
 | 115 | +    )?;  | 
 | 116 | +    writeln!(  | 
 | 117 | +        out,  | 
 | 118 | +        "{field:>width$}: {:?}",  | 
 | 119 | +        gix::path::env::system_prefix(),  | 
 | 120 | +        field = "system prefix",  | 
 | 121 | +    )?;  | 
 | 122 | +    Ok(())  | 
 | 123 | +}  | 
 | 124 | + | 
85 | 125 | #[cfg(all(feature = "async-client", feature = "blocking-client"))]  | 
86 | 126 | compile_error!("Cannot set both 'blocking-client' and 'async-client' features as they are mutually exclusive");  | 
87 | 127 | 
 
  | 
 | 
0 commit comments