feat: create new empty playlist via command (#272)
* feat: create new empty playlist via command - type :newplaylist <name> to create a new playlist fixes #242 * use full argument string for playlist name Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
This commit is contained in:
@@ -115,6 +115,7 @@ are supported:
|
|||||||
* `previous`/`next`: Play previous/next track
|
* `previous`/`next`: Play previous/next track
|
||||||
* `clear`: Clear playlist
|
* `clear`: Clear playlist
|
||||||
* `share [current | selected]`: Copies a sharable URL of either the selected item or the currernt song to the system clipboard
|
* `share [current | selected]`: Copies a sharable URL of either the selected item or the currernt song to the system clipboard
|
||||||
|
* `newplaylist <name>`: Create new playlist with name `<name>`
|
||||||
|
|
||||||
The screens can be opened with `queue`, `search`, `playlists` and `log`, whereas
|
The screens can be opened with `queue`, `search`, `playlists` and `log`, whereas
|
||||||
`search` can be supplied with a search term that will be entered after opening
|
`search` can be supplied with a search term that will be entered after opening
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ pub enum Command {
|
|||||||
ReloadConfig,
|
ReloadConfig,
|
||||||
Noop,
|
Noop,
|
||||||
Insert(Option<String>),
|
Insert(Option<String>),
|
||||||
|
NewPlaylist(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Command {
|
impl fmt::Display for Command {
|
||||||
@@ -171,6 +172,7 @@ impl fmt::Display for Command {
|
|||||||
Command::Help => "help".to_string(),
|
Command::Help => "help".to_string(),
|
||||||
Command::ReloadConfig => "reload".to_string(),
|
Command::ReloadConfig => "reload".to_string(),
|
||||||
Command::Insert(_) => "insert".to_string(),
|
Command::Insert(_) => "insert".to_string(),
|
||||||
|
Command::NewPlaylist(name) => format!("new playlist {}", name),
|
||||||
};
|
};
|
||||||
write!(f, "{}", repr)
|
write!(f, "{}", repr)
|
||||||
}
|
}
|
||||||
@@ -360,6 +362,13 @@ pub fn parse(input: &str) -> Option<Command> {
|
|||||||
.map(|url| Command::Insert(Some((*url).to_string())))
|
.map(|url| Command::Insert(Some((*url).to_string())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"newplaylist" => {
|
||||||
|
if !args.is_empty() {
|
||||||
|
Some(Command::NewPlaylist(args.join(" ")))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
"noop" => Some(Command::Noop),
|
"noop" => Some(Command::Noop),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,6 +184,13 @@ impl CommandManager {
|
|||||||
self.register_keybindings(s);
|
self.register_keybindings(s);
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
Command::NewPlaylist(name) => {
|
||||||
|
match self.spotify.create_playlist(name, None, None) {
|
||||||
|
Some(_) => self.library.update_library(),
|
||||||
|
None => error!("could not create playlist {}", name),
|
||||||
|
}
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
Command::Search(_)
|
Command::Search(_)
|
||||||
| Command::Jump(_)
|
| Command::Jump(_)
|
||||||
| Command::Move(_, _)
|
| Command::Move(_, _)
|
||||||
|
|||||||
Reference in New Issue
Block a user