/// A common method for returning the project directory and filepath. The method
/// will check for a passed argument set with -p but if it does not exist will
/// map the path for the .muxed directory in the users home directory and return
/// that as the default.
///
/// # Examples
///
/// #cfg(doctest) isn't working. This results in different home dirs
/// ```rust,no_run
/// use common::project_paths::{ProjectPaths, project_paths};
/// use common::args::Args;
/// use std::path::PathBuf;
///
/// let args = Args {
///     arg_project: "projectname".to_string(),
///     ..Default::default()
/// };
///
/// let project_paths = project_paths(&args);
///
/// let paths = ProjectPaths::new(
///     PathBuf::from("/tmp"),
///     PathBuf::from("/tmp/.muxed"),
///     PathBuf::from("/tmp/.muxed/projectname.yml")
/// );
///
/// assert_eq!(project_paths.home_directory, PathBuf::from("/tmp"));
/// assert_eq!(project_paths.project_directory, PathBuf::from("/tmp/.muxed"));
/// assert_eq!(project_paths.project_file, PathBuf::from("/tmp/.muxed/projectname.yml"))
/// ```
A common method for returning the project directory and filepath. The method
will check for a passed argument set with -p but if it does not exist will
map the path for the .muxed directory in the users home directory and return
that as the default.
A common method for returning the project directory and filepath . The method will check for a passed argument set with - p but if it does not exist will map the path for the . muxed directory in the users home directory and return that as the default .
pub fn project_paths(args: &Args) -> ProjectPaths {
    let homedir = homedir().expect("We couldn't find your home directory.");
    let default_dir = homedir.join(MUXED_FOLDER);
    let project_directory = args
        .flag_p
        .as_ref()
        .map_or(default_dir, |p| PathBuf::from(p));
    let project_filename = PathBuf::from(&args.arg_project).with_extension(CONFIG_EXTENSION);
    let project_fullpath = project_directory.join(project_filename);
    ProjectPaths::new(homedir, project_directory, project_fullpath)
}
pub fn project_paths ( args : & Args ) -> ProjectPaths { let homedir = homedir ( ) . expect ( " " ) ; let default_dir = homedir . join ( MUXED_FOLDER ) ; let project_directory = args . flag_p . as_ref ( ) . map_or ( default_dir , | p | PathBuf :: from ( p ) ) ; let project_filename = PathBuf :: from ( & args . arg_project ) . with_extension ( CONFIG_EXTENSION ) ; let project_fullpath = project_directory . join ( project_filename ) ; ProjectPaths :: new ( homedir , project_directory , project_fullpath ) }
A common method for returning the project directory and filepath.
A common method for returning the project directory and filepath .
args
&Args
examples
None
cfg(doctest) isn't working. this results in different home dirs
```rust,no_run
use common::project_paths::{ProjectPaths, project_paths};
use common::args::Args;
use std::path::PathBuf.

let args = Args {
arg_project: "projectname".to_string(),
Default::default()
}.

let project_paths = project_paths(&args).

let paths = ProjectPaths::new(
PathBuf::from("/tmp"),
PathBuf::from("/tmp/.muxed"),
PathBuf::from("/tmp/.muxed/projectname.yml")
).

assert_eq!(project_paths.home_directory, PathBuf::from("/tmp"));
assert_eq!(project_paths.project_directory, PathBuf::from("/tmp/.muxed"));
assert_eq!(project_paths.project_file, PathBuf::from("/tmp/.muxed/projectname.yml"))
```
` ` ` rust no_run use common :: project_paths :: { ProjectPaths project_paths } ; use common :: args :: Args ; use std :: path :: PathBuf . let args = Args { arg_project : " projectname " . to_string () Default :: default () } . let project_paths = project_paths ( &args ) . let paths = ProjectPaths :: new ( PathBuf :: from ( " / tmp " ) PathBuf :: from ( " / tmp / . muxed " ) PathBuf :: from ( " / tmp / . muxed / projectname . yml " ) ) . assert_eq! ( project_paths . home_directory PathBuf :: from ( " / tmp " )) ; assert_eq! ( project_paths . project_directory PathBuf :: from ( " / tmp / . muxed " )) ; assert_eq! ( project_paths . project_file PathBuf :: from ( " / tmp / . muxed / projectname . yml " )) ` ` `