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
+1
View File
@@ -73,6 +73,7 @@ The following formats are supported:
- [x] style option for invalid paths - [x] style option for invalid paths
- [x] subcommand to remove invalid paths - [x] subcommand to remove invalid paths
- [ ] print deleted bookmarks - [ ] print deleted bookmarks
- [ ] consistent output of `remove` subcommand
- [x] push <number> to push path in stack - [x] push <number> to push path in stack
- [x] write documentation - [x] write documentation
- [x] change config file extension to `.toml` - [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 /// 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) { 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()?; self.write_bookmark_file()?;
} else { } else {
return Err(Error::other( return Err(Error::other(
"-- bookmark requested to delete does not exist", "-- 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<()> { 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 { if config.general.show_entries_on_bookmark {
output.push_info(&bookmarks.to_formatted_string(config)?); output.push_info(&bookmarks.to_formatted_string(config)?);
} else { } 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(()) Ok(())
} }