(maybe_config: Result<Config, AppError>, project_name: &str, purge_directory: bool)
| 53 | } |
| 54 | |
| 55 | pub fn remove_project(maybe_config: Result<Config, AppError>, project_name: &str, purge_directory: bool) -> Result<(), AppError> { |
| 56 | let config: Config = maybe_config?; |
| 57 | |
| 58 | if !config.projects.contains_key(project_name) { |
| 59 | Err(AppError::UserError(format!("Project key {} does not exist in config", project_name))) |
| 60 | } else if let Some(project) = config.projects.get(project_name).cloned() { |
| 61 | if purge_directory { |
| 62 | let path = config.actual_path_to_project(&project); |
| 63 | |
| 64 | if path.exists() { |
| 65 | fs::remove_dir_all(&path)?; |
| 66 | } |
| 67 | } |
| 68 | config::delete_project_config(&project) |
| 69 | } else { |
| 70 | Err(AppError::UserError(format!("Unknown project {}", project_name))) |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | pub fn add_remote(maybe_config: Result<Config, AppError>, name: &str, remote_name: String, git: String) -> Result<(), AppError> { |
| 75 | let config: Config = maybe_config?; |
no test coverage detected