Changeset 5e61643 in gignore
- Timestamp:
- 21 Feb 2026, 19:27:29 (2 months ago)
- Branches:
- file_locations, help, logging, man, multi_arg, trunk
- Children:
- e36b2af
- Parents:
- eb42226
- File:
-
- 1 edited
-
src/template.rs (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/template.rs
reb42226 r5e61643 39 39 } 40 40 41 fn get_source_file(&self) -> &Path {41 fn get_source_file(&self) -> &PathBuf { 42 42 &self.source_file 43 43 } … … 103 103 let mut template_vec: Vec<Template> = lib_read().context("cannot read template library")?; 104 104 105 match template_vec.extract_if(.., |item| item.get_name() == name).next() { 106 None => { return Err(Error::msg(format!("No template under the name `{name}`"))) }, 107 _ => {}, 105 template_vec.extract_if(.., |item| item.get_name() == name).for_each(drop); 106 107 let template = match find_name(name).context(format!("cannot search for name {name} in /usr/lib/gignore/gignore_templates"))? { 108 None => { 109 eprintln!("No template exists in `/usr/lib/gignore/gignore_templates` under the name `{name}`."); 110 process::exit(0); 111 }, 112 Some(t) => t, 108 113 }; 109 114 … … 111 116 112 117 if template_vec.is_empty() { 113 println!(" template lib fileis now empty.");118 println!("{path} is now empty."); 114 119 fs::write(path, b"").context("cannot write to `/usr/lib/gignore/gignore_templates`")?; 115 120 } else { … … 118 123 } 119 124 } 125 126 fs::remove_file(template.get_source_file()).context(format!("cannot remove `{}`", template.get_source_file().display()))?; 120 127 Ok(()) 121 128 } … … 126 133 } 127 134 128 if ( &*(template.get_source_file().to_string_lossy())).split_terminator('.').nth(2) != Some("ggnr") {135 if (*(template.get_source_file())).to_str().expect("FATAL: Could not convert source_file to string!").split_terminator('.').nth(2) != Some("ggnr") { 129 136 eprintln!("WARNING: specified source file, `{}`, does not have the file extension for gignore templates (`.ggnr`). Continue anyway? [y/N]", template.get_source_file().display()); 130 137 … … 157 164 eprintln!("Continuing..."); 158 165 159 fs::remove (&new_template_path).166 fs::remove_file(&new_template_path).context(format!("cannot remove {new_template_path}"))? 160 167 }, 161 168 _ => { … … 163 170 process::exit(0); 164 171 }, 165 } 172 }; 166 173 }; 167 174
Note:
See TracChangeset
for help on using the changeset viewer.
