pub fn load_snapshot(
    options: &CliOptions,
    config_snapshot_file: &Option<PathBuf>,
) -> (Snapshot, PathBuf) {
    // if option "-p" is present, use it, or use the config tag or build a new name from config file
    let snapfile = if options.snapshot_file.is_some() {
        options.snapshot_file.as_ref().unwrap().clone()
    // it's given as a command line argument as '--snapshot'
    } else if config_snapshot_file.is_some() {
        // or it's using what's defined in the configuration file
        let conf_file_or_dir = config_snapshot_file.as_ref().unwrap();

        // if what is specified is a directory, use this to build the final snapshot file
        if conf_file_or_dir.is_dir() {
            Snapshot::build_name(&options.config_file, Some(conf_file_or_dir))
        } else {
            conf_file_or_dir.clone()
        }
    } else {
        // otherwise, the snapshot file is build from the config file, adding .json extension
        Snapshot::build_name(&options.config_file, None)
    };

    // delete snapshot file if requested
    if options.delete_snapfile {
        if let Err(e) = std::fs::remove_file(&snapfile) {
            // 'not found' could be a viable error
            if e.kind() != std::io::ErrorKind::NotFound {
                error!(
                    "unable to delete snapshot file: {:?}, error: {}",
                    &snapfile, e
                );
            }
        } else {
            info!("deleting snapshot file {:?}", &snapfile);
        }
    }
    info!("using snapshot file:{}", &snapfile.display());

    // read snapshot data from file
    let snapshot = Snapshot::load(&snapfile)
        .expect_critical(&format!("unable to load snapshot file: {:?},", &snapfile));
    info!(
        "loaded snapshot file {:?}, data = {:#?}",
        &snapfile, &snapshot
    );

    (snapshot, snapfile)
}
/// Load the snapshot file: if option "-p" is present, use it, or use the config tag or build a new name from config file
Load the snapshot file: if option "-p" is present, use it, or use the config tag or build a new name from config file
Load the snapshot file : if option " - p " is present use it or use the config tag or build a new name from config file
pub fn load_snapshot(
    options: &CliOptions,
    config_snapshot_file: &Option<PathBuf>,
) -> (Snapshot, PathBuf) {
    // if option "-p" is present, use it, or use the config tag or build a new name from config file
    let snapfile = if options.snapshot_file.is_some() {
        options.snapshot_file.as_ref().unwrap().clone()
    // it's given as a command line argument as '--snapshot'
    } else if config_snapshot_file.is_some() {
        // or it's using what's defined in the configuration file
        let conf_file_or_dir = config_snapshot_file.as_ref().unwrap();
        // if what is specified is a directory, use this to build the final snapshot file
        if conf_file_or_dir.is_dir() {
            Snapshot::build_name(&options.config_file, Some(conf_file_or_dir))
        } else {
            conf_file_or_dir.clone()
        }
    } else {
        // otherwise, the snapshot file is build from the config file, adding .json extension
        Snapshot::build_name(&options.config_file, None)
    };
    // delete snapshot file if requested
    if options.delete_snapfile {
        if let Err(e) = std::fs::remove_file(&snapfile) {
            // 'not found' could be a viable error
            if e.kind() != std::io::ErrorKind::NotFound {
                error!(
                    "unable to delete snapshot file: {:?}, error: {}",
                    &snapfile, e
                );
            }
        } else {
            info!("deleting snapshot file {:?}", &snapfile);
        }
    }
    info!("using snapshot file:{}", &snapfile.display());
    // read snapshot data from file
    let snapshot = Snapshot::load(&snapfile)
        .expect_critical(&format!("unable to load snapshot file: {:?},", &snapfile));
    info!(
        "loaded snapshot file {:?}, data = {:#?}",
        &snapfile, &snapshot
    );
    (snapshot, snapfile)
}
pub fn load_snapshot ( options : & CliOptions , config_snapshot_file : & Option < PathBuf > , ) -> ( Snapshot , PathBuf ) { // if option "-p" is present, use it, or use the config tag or build a new name from config file let snapfile = if options . snapshot_file . is_some ( ) { options . snapshot_file . as_ref ( ) . unwrap ( ) . clone ( ) // it's given as a command line argument as '--snapshot' } else if config_snapshot_file . is_some ( ) { // or it's using what's defined in the configuration file let conf_file_or_dir = config_snapshot_file . as_ref ( ) . unwrap ( ) ; // if what is specified is a directory, use this to build the final snapshot file if conf_file_or_dir . is_dir ( ) { Snapshot :: build_name ( & options . config_file , Some ( conf_file_or_dir ) ) } else { conf_file_or_dir . clone ( ) } } else { // otherwise, the snapshot file is build from the config file, adding .json extension Snapshot :: build_name ( & options . config_file , None ) } ; // delete snapshot file if requested if options . delete_snapfile { if let Err ( e ) = std :: fs :: remove_file ( & snapfile ) { // 'not found' could be a viable error if e . kind ( ) != std :: io :: ErrorKind :: NotFound { error ! ( " " snapfile e ) ; } } else { info ! ( " " snapfile ) ; } } info ! ( " " snapfile display ( ) ) ; // read snapshot data from file let snapshot = Snapshot :: load ( & snapfile ) . expect_critical ( & format ! ( " " snapfile ) ) ; info ! ( " " snapfile snapshot ) ; ( snapshot , snapfile ) }
Load the snapshot file: if option "-p" is present, use it, or use the config tag or build a new name from config file
Load the snapshot file : if option " - p " is present use it or use the config tag or build a new name from config file
options
&CliOptions
config_snapshot_file
&Option<PathBuf>
options
&CliOptions
config_snapshot_file
&Option<PathBuf>