improved output of book remove & added todo

This commit is contained in:
scbj
2025-07-09 10:39:33 +02:00
parent 3eee1e304c
commit 4e8c311476
3 changed files with 12 additions and 7 deletions
+3 -2
View File
@@ -71,8 +71,9 @@ The following formats are supported:
- [x] do not resolve links in bookmarks
- [x] option to show invalid paths
- [x] style option for invalid paths
- [x] subcommand to remove invalid paths
- [ ] print deleted bookmarks
- [x] subcommand to remove invalid paths
- [ ] print deleted bookmarks
- [ ] consistent output of `remove` subcommand
- [x] push <number> to push path in stack
- [x] write documentation
- [x] change config file extension to `.toml`
+7 -3
View File
@@ -89,16 +89,20 @@ impl Bookmarks {
}
/// removes a the entry with key=name if it exists, then writes the bookmarks file
pub fn remove_bookmark(&mut self, name: &String) -> Result<()> {
pub fn remove_bookmark(&mut self, name: &String) -> Result<PathBuf> {
let path: PathBuf;
if self.bookmarks.contains_key(name) {
_ = self.bookmarks.remove(name);
path = match self.bookmarks.remove(name) {
Some(path) => path,
None => return Err(Error::other("-- those bastards, they lied to me!")),
};
self.write_bookmark_file()?;
} else {
return Err(Error::other(
"-- bookmark requested to delete does not exist",
));
}
Ok(())
Ok(path)
}
///
+2 -2
View File
@@ -214,12 +214,12 @@ fn add_bookmarks(args: &BookmarkSubArgs, config: &Config, bookmarks: &mut Bookma
}
fn remove_bookmarks(args: &BookmarkSubArgs, config: &Config, bookmarks: &mut Bookmarks, output: &mut Output) -> Result<()> {
bookmarks.remove_bookmark(&args.name)?;
let path = bookmarks.remove_bookmark(&args.name)?;
if config.general.show_entries_on_bookmark {
output.push_info(&bookmarks.to_formatted_string(config)?);
} else {
output.push_info(&format!("remove bookmark `{}{}{}`.", generate_style_sequence(Some(STYLES.set.bold), None, None), args.name, RESET_SEQ));
output.push_info(&format!("removed bookmark `{}{}{}{}{}`.", generate_style_sequence(Some(STYLES.set.bold), None, None), args.name, config.format.bookmarks_separator, path.to_str().unwrap(), RESET_SEQ));
}
Ok(())
}