MCPcopy Create free account
hub / github.com/brocode/fw / write_tag

Function write_tag

src/config/mod.rs:130–149  ·  view source on GitHub ↗
(tag_name: &str, tag: &Tag)

Source from the content-addressed store, hash-verified

128}
129
130pub 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
151pub fn delete_tag_config(tag_name: &str, tag: &Tag) -> Result<(), AppError> {
152 let paths = fw_path()?;

Callers 1

create_tagFunction · 0.85

Calls 3

fw_pathFunction · 0.85
write_exampleFunction · 0.85
ensure_base_existsMethod · 0.80

Tested by

no test coverage detected