cli: make `rad debug` work without a profile
Reported-by: Lorenz Leutgeb Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
parent
0834e0fc7d
commit
db98daecca
|
|
@ -46,17 +46,17 @@ impl Args for Options {
|
||||||
|
|
||||||
pub fn run(_options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
pub fn run(_options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
match ctx.profile() {
|
match ctx.profile() {
|
||||||
Ok(profile) => debug(&profile),
|
Ok(profile) => debug(Some(&profile)),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("ERROR: {e}");
|
eprintln!("ERROR: Could not load Radicle profile: {e}");
|
||||||
Err(e)
|
debug(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect information about the local Radicle installation and write
|
// Collect information about the local Radicle installation and write
|
||||||
// it out.
|
// it out.
|
||||||
fn debug(profile: &Profile) -> anyhow::Result<()> {
|
fn debug(profile: Option<&Profile>) -> anyhow::Result<()> {
|
||||||
let env = HashMap::from_iter(env::vars().filter_map(|(k, v)| {
|
let env = HashMap::from_iter(env::vars().filter_map(|(k, v)| {
|
||||||
if k == "RAD_PASSPHRASE" {
|
if k == "RAD_PASSPHRASE" {
|
||||||
Some((k, "<REDACTED>".into()))
|
Some((k, "<REDACTED>".into()))
|
||||||
|
|
@ -81,8 +81,8 @@ fn debug(profile: &Profile) -> anyhow::Result<()> {
|
||||||
git_version: stdout_of("git", &["--version"]).unwrap_or("<unknown>".into()),
|
git_version: stdout_of("git", &["--version"]).unwrap_or("<unknown>".into()),
|
||||||
ssh_version: stderr_of("ssh", &["-V"]).unwrap_or("<unknown>".into()),
|
ssh_version: stderr_of("ssh", &["-V"]).unwrap_or("<unknown>".into()),
|
||||||
git_head: GIT_HEAD,
|
git_head: GIT_HEAD,
|
||||||
log: LogFile::new(profile.node().join("node.log")),
|
log: profile.map(|p| LogFile::new(p.node().join("node.log"))),
|
||||||
old_log: LogFile::new(profile.node().join("node.log.old")),
|
old_log: profile.map(|p| LogFile::new(p.node().join("node.log.old"))),
|
||||||
operating_system: std::env::consts::OS,
|
operating_system: std::env::consts::OS,
|
||||||
arch: std::env::consts::ARCH,
|
arch: std::env::consts::ARCH,
|
||||||
env,
|
env,
|
||||||
|
|
@ -104,8 +104,8 @@ struct DebugInfo {
|
||||||
git_version: String,
|
git_version: String,
|
||||||
ssh_version: String,
|
ssh_version: String,
|
||||||
git_head: &'static str,
|
git_head: &'static str,
|
||||||
log: LogFile,
|
log: Option<LogFile>,
|
||||||
old_log: LogFile,
|
old_log: Option<LogFile>,
|
||||||
operating_system: &'static str,
|
operating_system: &'static str,
|
||||||
arch: &'static str,
|
arch: &'static str,
|
||||||
env: HashMap<String, String>,
|
env: HashMap<String, String>,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue