fn establish_path(opts: &InitOptions, potential_path: &Path) -> Result<InitStatus, DiaryError> {
    if potential_path == PathBuf::from("") {
        let diary_path = opts.path.join("diary");
        if diary_path.exists() {
            return Err(DiaryError::ExistsHere);
        }
        Ok(InitStatus::UseOpt(diary_path))
    } else if potential_path.exists() {
        Err(DiaryError::ExistsElsewhere)
    } else {
        Ok(InitStatus::UseConfig(potential_path.to_path_buf()))
    }
}
/// Establishes where the diary folder should be initialised.
///
/// # Arguments
///
/// * `opts` - The options passed by the user at runtime.
/// * `potential_path` - The potential location of the diary folder, as defined in the config.
///
/// # Returns
///
/// Either the initialisation status, which provides the path to use, or a DiaryError
/// if the diary is already initialised somewhere.
Establishes where the diary folder should be initialised.
Establishes where the diary folder should be initialised .
fn establish_path(opts: &InitOptions, potential_path: &Path) -> Result<InitStatus, DiaryError> {
    if potential_path == PathBuf::from("") {
        let diary_path = opts.path.join("diary");
        if diary_path.exists() {
            return Err(DiaryError::ExistsHere);
        }
        Ok(InitStatus::UseOpt(diary_path))
    } else if potential_path.exists() {
        Err(DiaryError::ExistsElsewhere)
    } else {
        Ok(InitStatus::UseConfig(potential_path.to_path_buf()))
    }
}
fn establish_path ( opts : & InitOptions , potential_path : & Path ) -> Result < InitStatus , DiaryError > { if potential_path == PathBuf :: from ( " " ) { let diary_path = opts . path . join ( " " ) ; if diary_path . exists ( ) { return Err ( DiaryError :: ExistsHere ) ; } Ok ( InitStatus :: UseOpt ( diary_path ) ) } else if potential_path . exists ( ) { Err ( DiaryError :: ExistsElsewhere ) } else { Ok ( InitStatus :: UseConfig ( potential_path . to_path_buf ( ) ) ) } }
Establishes where the diary folder should be initialised.
Establishes where the diary folder should be initialised .
opts
&InitOptions
potential_path
&Path
Either the initialisation status, which provides the path to use, or a DiaryError
if the diary is already initialised somewhere.
Either the initialisation status which provides the path to use or a DiaryError if the diary is already initialised somewhere .
opts
&InitOptions
potential_path
&Path