feat: add file name indicator at the top of the editor buffer
This commit is contained in:
+7
-2
@@ -1,5 +1,4 @@
|
|||||||
use lofty::config::WriteOptions;
|
use lofty::config::WriteOptions;
|
||||||
use lofty::prelude::ItemKey::AlbumTitle;
|
|
||||||
use lofty::tag::TagItem;
|
use lofty::tag::TagItem;
|
||||||
use lofty::tag::TagType::VorbisComments;
|
use lofty::tag::TagType::VorbisComments;
|
||||||
use lofty::tag::{ItemKey, ItemValue};
|
use lofty::tag::{ItemKey, ItemValue};
|
||||||
@@ -14,6 +13,11 @@ pub fn edit(file_path: PathBuf, mut tag: Tag) -> std::io::Result<()> {
|
|||||||
let tmp_file = PathBuf::from("/tmp/keks-sort-metadata");
|
let tmp_file = PathBuf::from("/tmp/keks-sort-metadata");
|
||||||
let editor = var("EDITOR").unwrap();
|
let editor = var("EDITOR").unwrap();
|
||||||
let mut file = File::create(&tmp_file)?;
|
let mut file = File::create(&tmp_file)?;
|
||||||
|
writeln!(
|
||||||
|
file.try_clone()?,
|
||||||
|
"------------ {:?} ------------",
|
||||||
|
file_path
|
||||||
|
)?;
|
||||||
for item in tag.items() {
|
for item in tag.items() {
|
||||||
writeln!(
|
writeln!(
|
||||||
file,
|
file,
|
||||||
@@ -35,7 +39,8 @@ pub fn edit(file_path: PathBuf, mut tag: Tag) -> std::io::Result<()> {
|
|||||||
|
|
||||||
let parsed = parse(&editable);
|
let parsed = parse(&editable);
|
||||||
for (key, value) in parsed {
|
for (key, value) in parsed {
|
||||||
let item_key = ItemKey::from_key(VorbisComments, &key).expect("Failed to get item key");
|
let item_key =
|
||||||
|
ItemKey::from_key(VorbisComments, &key).expect("ERROR: Failed to get item key");
|
||||||
let item = TagItem::new(item_key, ItemValue::Text(value));
|
let item = TagItem::new(item_key, ItemValue::Text(value));
|
||||||
tag.insert(item.clone());
|
tag.insert(item.clone());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user