cargo_mobile2/doctor/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
mod section;

use crate::{
    env,
    os::Env,
    util::{self, cli::TextWrapper},
};
use thiserror::Error;

// This should only be used for errors that we *really* don't expect and/or
// that violate core assumptions made throughout the program.
#[derive(Debug, Error)]
pub enum Unrecoverable {
    // Only encountered if the most basic environment variables are absent or
    // unreadable
    #[error(transparent)]
    EnvInitFailed(#[from] env::Error),
    // Only encountered if A) the user has no home directory, or B) either the
    // home or some other path isn't valid UTF-8
    #[error("Failed to prettify path: {0}")]
    ContractHomeFailed(#[from] util::ContractHomeError),
}

pub fn exec(wrapper: &TextWrapper) -> Result<(), Unrecoverable> {
    let env = Env::new()?;
    section::cargo_mobile::check()?.print(wrapper);
    #[cfg(target_os = "macos")]
    section::apple::check().print(wrapper);
    section::android::check(&env)?.print(wrapper);
    section::device_list::check(&env).print(wrapper);
    Ok(())
}