Finished implementing clear command.

This commit is contained in:
Jonathan Bernard 2016-03-04 20:53:57 -06:00
parent f80ff182ad
commit 7cad273a0b
2 changed files with 22 additions and 3 deletions

View File

@ -54,7 +54,8 @@ play playlist <id | name>
clear
queue
playlist
playlist < id | name >
selected playlist
selection
* Transport operations

View File

@ -386,10 +386,28 @@ Configuration:
private def processClear(LinkedList line) {
def option = line.poll()
switch(option) {
case 'queue': library.removeAllFromPlaylist(playQueue.id)
case 'queue': return library.removeAllFromPlaylist(playQueue.id)
case 'selected playlist':
if (!selection.playlist) {
printLongMessage("No playlist currently selected.")
return null }
return library.removeAllFromPlaylist(selected.playlist.id)
case 'playlist':
def criteria = line.poll()
if (!criteria) {
printLongMessage("Missing playlist id or name. Use " +
"${promptStyle}help clear${normalStyle} to see a " +
"list of valid options.")
return null }
def playlist = library.getByIdOrName(Playlist, criteria)
if (!playlist) {
printLongMessage("No playlist matches '${criteria}'.")
return null }
return library.removeAllFromPlaylist(playlist.id)
case 'selection':
default:
printLongMessage("Unrecognized option to the ${promptStyle}" +
"add${normalStyle} command. Use ${promptStyle}help add" +
"add${normalStyle} command. Use ${promptStyle}help clear" +
"${normalStyle} to see a list of valid options.")
return null
}