pub fn initialize(options: Options) -> Result<StateHolder, Error> {
    let Options { inspect, config_files, .. } = options;
    let inspect_text = match fs::read_to_string(inspect.clone()) {
        Ok(data) => data,
        Err(_) => bail!("Couldn't read Inspect file '{}' to string", inspect),
    };
    let inspect_data = parse_inspect(inspect_text)?;

    if config_files.len() == 0 {
        bail!("Need at least one config file; use --config");
    }
    let mut actions = HashMap::new();
    let mut metrics = HashMap::new();
    let mut tests = HashMap::new();
    for file_name in config_files {
        let namespace = base_name(&file_name)?;
        let file_data = match fs::read_to_string(file_name.clone()) {
            Ok(data) => data,
            Err(_) => bail!("Couldn't read config file '{}' to string", file_name),
        };
        let file_config = match ConfigFileSchema::parse(file_data) {
            Ok(c) => c,
            Err(e) => bail!("Parsing file '{}': {}", file_name, e),
        };
        let ConfigFileSchema { actions: file_actions, metrics: file_metrics, tests: file_tests } =
            file_config;
        metrics.insert(namespace.clone(), file_metrics);
        actions.insert(namespace.clone(), file_actions);
        tests.insert(namespace, file_tests);
    }
    validate(&metrics, &actions, &tests)?;
    Ok(StateHolder { metrics, actions, inspect_data })
}
/// Parses the inspect.json file and all the config files.
Parses the inspect.json file and all the config files.
Parses the inspect . json file and all the config files .
pub fn initialize(options: Options) -> Result<StateHolder, Error> {
    let Options { inspect, config_files, .. } = options;
    let inspect_text = match fs::read_to_string(inspect.clone()) {
        Ok(data) => data,
        Err(_) => bail!("Couldn't read Inspect file '{}' to string", inspect),
    };
    let inspect_data = parse_inspect(inspect_text)?;
    if config_files.len() == 0 {
        bail!("Need at least one config file; use --config");
    }
    let mut actions = HashMap::new();
    let mut metrics = HashMap::new();
    let mut tests = HashMap::new();
    for file_name in config_files {
        let namespace = base_name(&file_name)?;
        let file_data = match fs::read_to_string(file_name.clone()) {
            Ok(data) => data,
            Err(_) => bail!("Couldn't read config file '{}' to string", file_name),
        };
        let file_config = match ConfigFileSchema::parse(file_data) {
            Ok(c) => c,
            Err(e) => bail!("Parsing file '{}': {}", file_name, e),
        };
        let ConfigFileSchema { actions: file_actions, metrics: file_metrics, tests: file_tests } =
            file_config;
        metrics.insert(namespace.clone(), file_metrics);
        actions.insert(namespace.clone(), file_actions);
        tests.insert(namespace, file_tests);
    }
    validate(&metrics, &actions, &tests)?;
    Ok(StateHolder { metrics, actions, inspect_data })
}
pub fn initialize ( options : Options ) -> Result < StateHolder , Error > { let Options { inspect , config_files , .. } = options ; let inspect_text = match fs :: read_to_string ( inspect . clone ( ) ) { Ok ( data ) => data , Err ( _ ) => bail ! ( " " inspect ) , } ; let inspect_data = parse_inspect ( inspect_text ) ? ; if config_files . len ( ) == 0 { bail ! ( " " ) ; } let mut actions = HashMap :: new ( ) ; let mut metrics = HashMap :: new ( ) ; let mut tests = HashMap :: new ( ) ; for file_name in config_files { let namespace = base_name ( & file_name ) ? ; let file_data = match fs :: read_to_string ( file_name . clone ( ) ) { Ok ( data ) => data , Err ( _ ) => bail ! ( " " file_name ) , } ; let file_config = match ConfigFileSchema :: parse ( file_data ) { Ok ( c ) => c , Err ( e ) => bail ! ( " " file_name e ) , } ; let ConfigFileSchema { actions : file_actions , metrics : file_metrics , tests : file_tests } = file_config ; metrics . insert ( namespace . clone ( ) , file_metrics ) ; actions . insert ( namespace . clone ( ) , file_actions ) ; tests . insert ( namespace , file_tests ) ; } validate ( & metrics , & actions , & tests ) ? ; Ok ( StateHolder { metrics , actions , inspect_data } ) }
Parses the inspect.json file and all the config files.
Parses the inspect . json file and all the config files .
options
Options