(workspace_dir: &str)
| 44 | } |
| 45 | |
| 46 | pub fn setup(workspace_dir: &str) -> Result<(), AppError> { |
| 47 | let path = PathBuf::from(workspace_dir); |
| 48 | let maybe_path = if path.exists() { |
| 49 | Ok(path) |
| 50 | } else { |
| 51 | Err(AppError::UserError(format!("Given workspace path {} does not exist", workspace_dir))) |
| 52 | }; |
| 53 | |
| 54 | maybe_path |
| 55 | .and_then(|path| { |
| 56 | if path.is_absolute() { |
| 57 | Ok(path) |
| 58 | } else { |
| 59 | Err(AppError::UserError(format!("Workspace path {} needs to be absolute", workspace_dir))) |
| 60 | } |
| 61 | }) |
| 62 | .and_then(determine_projects) |
| 63 | .and_then(|projects| write_new_config_with_projects(projects, workspace_dir)) |
| 64 | } |
| 65 | |
| 66 | fn determine_projects(path: PathBuf) -> Result<BTreeMap<String, Project>, AppError> { |
| 67 | let workspace_path = path.clone(); |
no test coverage detected