feat: add save current command
This commit is contained in:
committed by
Henrik Friedrichsen
parent
2c61a965f1
commit
f74661a15d
@@ -132,6 +132,7 @@ pub enum Command {
|
|||||||
Play,
|
Play,
|
||||||
UpdateLibrary,
|
UpdateLibrary,
|
||||||
Save,
|
Save,
|
||||||
|
SaveCurrent,
|
||||||
SaveQueue,
|
SaveQueue,
|
||||||
Delete,
|
Delete,
|
||||||
Focus(String),
|
Focus(String),
|
||||||
@@ -213,6 +214,7 @@ impl fmt::Display for Command {
|
|||||||
| Command::Play
|
| Command::Play
|
||||||
| Command::UpdateLibrary
|
| Command::UpdateLibrary
|
||||||
| Command::Save
|
| Command::Save
|
||||||
|
| Command::SaveCurrent
|
||||||
| Command::SaveQueue
|
| Command::SaveQueue
|
||||||
| Command::Delete
|
| Command::Delete
|
||||||
| Command::Back
|
| Command::Back
|
||||||
@@ -242,6 +244,7 @@ impl Command {
|
|||||||
Command::Play => "play",
|
Command::Play => "play",
|
||||||
Command::UpdateLibrary => "update",
|
Command::UpdateLibrary => "update",
|
||||||
Command::Save => "save",
|
Command::Save => "save",
|
||||||
|
Command::SaveCurrent => "save current",
|
||||||
Command::SaveQueue => "save queue",
|
Command::SaveQueue => "save queue",
|
||||||
Command::Delete => "delete",
|
Command::Delete => "delete",
|
||||||
Command::Focus(_) => "focus",
|
Command::Focus(_) => "focus",
|
||||||
@@ -388,6 +391,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
|
|||||||
"update" => Command::UpdateLibrary,
|
"update" => Command::UpdateLibrary,
|
||||||
"save" => match args.first().cloned() {
|
"save" => match args.first().cloned() {
|
||||||
Some("queue") => Ok(Command::SaveQueue),
|
Some("queue") => Ok(Command::SaveQueue),
|
||||||
|
Some("current") => Ok(Command::SaveCurrent),
|
||||||
Some(arg) => Err(BadEnumArg {
|
Some(arg) => Err(BadEnumArg {
|
||||||
arg: arg.into(),
|
arg: arg.into(),
|
||||||
accept: vec!["**omit**".into(), "queue".into()],
|
accept: vec!["**omit**".into(), "queue".into()],
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use crate::ext_traits::CursiveExt;
|
|||||||
use crate::library::Library;
|
use crate::library::Library;
|
||||||
use crate::queue::{Queue, RepeatSetting};
|
use crate::queue::{Queue, RepeatSetting};
|
||||||
use crate::spotify::{Spotify, VOLUME_PERCENT};
|
use crate::spotify::{Spotify, VOLUME_PERCENT};
|
||||||
use crate::traits::{IntoBoxedViewExt, ViewExt};
|
use crate::traits::{IntoBoxedViewExt, ListItem, ViewExt};
|
||||||
use crate::ui::contextmenu::{
|
use crate::ui::contextmenu::{
|
||||||
AddToPlaylistMenu, ContextMenu, SelectArtistActionMenu, SelectArtistMenu,
|
AddToPlaylistMenu, ContextMenu, SelectArtistActionMenu, SelectArtistMenu,
|
||||||
};
|
};
|
||||||
@@ -272,6 +272,12 @@ impl CommandManager {
|
|||||||
self.spotify.shutdown();
|
self.spotify.shutdown();
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
Command::SaveCurrent => {
|
||||||
|
if let Some(mut track) = self.queue.get_current() {
|
||||||
|
track.save(&self.library);
|
||||||
|
}
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
|
||||||
Command::Queue
|
Command::Queue
|
||||||
| Command::PlayNext
|
| Command::PlayNext
|
||||||
|
|||||||
Reference in New Issue
Block a user