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 @@ pub enum Command {
|
||||
ReloadConfig,
|
||||
Noop,
|
||||
Insert(Option<String>),
|
||||
NewPlaylist(String),
|
||||
}
|
||||
|
||||
impl fmt::Display for Command {
|
||||
@@ -171,6 +172,7 @@ impl fmt::Display for Command {
|
||||
Command::Help => "help".to_string(),
|
||||
Command::ReloadConfig => "reload".to_string(),
|
||||
Command::Insert(_) => "insert".to_string(),
|
||||
Command::NewPlaylist(name) => format!("new playlist {}", name),
|
||||
};
|
||||
write!(f, "{}", repr)
|
||||
}
|
||||
@@ -360,6 +362,13 @@ pub fn parse(input: &str) -> Option<Command> {
|
||||
.map(|url| Command::Insert(Some((*url).to_string())))
|
||||
}
|
||||
}
|
||||
"newplaylist" => {
|
||||
if !args.is_empty() {
|
||||
Some(Command::NewPlaylist(args.join(" ")))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
"noop" => Some(Command::Noop),
|
||||
_ => None,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user