(tag_name: &str, tag: &Tag)
| 128 | } |
| 129 | |
| 130 | pub fn write_tag(tag_name: &str, tag: &Tag) -> Result<(), AppError> { |
| 131 | let paths = fw_path()?; |
| 132 | paths.ensure_base_exists()?; |
| 133 | |
| 134 | let mut tag_path = paths.tags; |
| 135 | tag_path.push(PathBuf::from(&tag.tag_config_path)); |
| 136 | std::fs::create_dir_all(&tag_path) |
| 137 | .map_err(|e| AppError::RuntimeError(format!("Failed to create tag config path '{}'. {}", tag_path.to_string_lossy(), e)))?; |
| 138 | |
| 139 | let mut tag_file_path = tag_path; |
| 140 | tag_file_path.push(tag_name); |
| 141 | |
| 142 | let mut buffer = File::create(&tag_file_path) |
| 143 | .map_err(|e| AppError::RuntimeError(format!("Failed to create project config file '{}'. {}", tag_file_path.to_string_lossy(), e)))?; |
| 144 | let serialized = toml::to_string_pretty(&tag)?; |
| 145 | write!(buffer, "{}", CONF_MODE_HEADER)?; |
| 146 | write!(buffer, "{}", serialized)?; |
| 147 | write_example(&mut buffer, Tag::example())?; |
| 148 | Ok(()) |
| 149 | } |
| 150 | |
| 151 | pub fn delete_tag_config(tag_name: &str, tag: &Tag) -> Result<(), AppError> { |
| 152 | let paths = fw_path()?; |
no test coverage detected