pub fn init(opts: &InitOptions, potential_path: &Path) -> Result<PathBuf, DiaryError> {
    let init_status = establish_path(opts, potential_path);
    let path = match init_status? {
        InitStatus::UseConfig(path) => {
            print!("It appears the config file already has a diary path set. ");
            println!("Creating a diary folder here: {:?}", path);
            path
        }
        InitStatus::UseOpt(path) => {
            println!("Creating a diary folder.");
            path
        }
    };
    let path = match create_dir_all(&path) {
        Ok(_) => path,
        Err(e) => return Err(DiaryError::from(e)), // uncovered.
    };

    if opts.git_repo {
        match Repository::init(&path) {
            Ok(_) => (),
            Err(e) => return Err(DiaryError::from(e)), // uncovered.
        };
    };
    Ok(path)
}
/// Initialises the diary folder, if possible.
///
/// # Arguments
///
/// * `opts` - The options passed by the user at runtime.
/// * `config` - The contents of the config file.
///
/// # Returns
///
/// Either the Path of the new diary folder or a DiaryError if there was an
/// issue with initialisation.
Initialises the diary folder, if possible.
Initialises the diary folder if possible .
pub fn init(opts: &InitOptions, potential_path: &Path) -> Result<PathBuf, DiaryError> {
    let init_status = establish_path(opts, potential_path);
    let path = match init_status? {
        InitStatus::UseConfig(path) => {
            print!("It appears the config file already has a diary path set. ");
            println!("Creating a diary folder here: {:?}", path);
            path
        }
        InitStatus::UseOpt(path) => {
            println!("Creating a diary folder.");
            path
        }
    };
    let path = match create_dir_all(&path) {
        Ok(_) => path,
        Err(e) => return Err(DiaryError::from(e)), // uncovered.
    };
    if opts.git_repo {
        match Repository::init(&path) {
            Ok(_) => (),
            Err(e) => return Err(DiaryError::from(e)), // uncovered.
        };
    };
    Ok(path)
}
pub fn init ( opts : & InitOptions , potential_path : & Path ) -> Result < PathBuf , DiaryError > { let init_status = establish_path ( opts , potential_path ) ; let path = match init_status ? { InitStatus :: UseConfig ( path ) => { print ! ( " " ) ; println ! ( " " path ) ; path } InitStatus :: UseOpt ( path ) => { println ! ( " " ) ; path } } ; let path = match create_dir_all ( & path ) { Ok ( _ ) => path , Err ( e ) => return Err ( DiaryError :: from ( e ) ) , // uncovered. } ; if opts . git_repo { match Repository :: init ( & path ) { Ok ( _ ) => ( ) , Err ( e ) => return Err ( DiaryError :: from ( e ) ) , // uncovered. } ; } ; Ok ( path ) }
Initialises the diary folder, if possible.
Initialises the diary folder if possible .
opts
&InitOptions
potential_path
&Path
Either the Path of the new diary folder or a DiaryError if there was an
issue with initialisation.
Either the Path of the new diary folder or a DiaryError if there was an issue with initialisation .
opts
&InitOptions
potential_path
&Path