Added CLI helper to print invalid options errors for commands.

This commit is contained in:
Jonathan Bernard 2016-03-21 01:13:44 -05:00
parent 3d65a47781
commit 72b4b0c9ff

View File

@ -454,11 +454,7 @@ Configuration:
modelClass = modelClasses[Matcher.lastMatcher[0][1]] modelClass = modelClasses[Matcher.lastMatcher[0][1]]
return library.getWhere(modelClass, [playlistId: playQueue.id]) return library.getWhere(modelClass, [playlistId: playQueue.id])
case ~/untagged files/: return library.untaggedFiles case ~/untagged files/: return library.untaggedFiles
default: default: invalidOptionsErr('select') } }
logger.debug("Invalid select options: $options")
err "Invalid options to the ${cmdStyle}select${normalStyle}" +
" command. Use ${cmdStyle}help select${normalStyle} to " +
"see a list of valid options." } }
private Playlist processPlay(String options, List<Model> selection) { private Playlist processPlay(String options, List<Model> selection) {
@ -1040,7 +1036,6 @@ Play and Controlling Media:
Playlist and Queue Management: Playlist and Queue Management:
scan
enqueue selection enqueue selection
enqueue <selection-criteria> enqueue <selection-criteria>
@ -1063,6 +1058,9 @@ Playlist and Queue Management:
clear selection clear selection
clear playlist <id | name> clear playlist <id | name>
Library Management:
scan
""" """
default: default:
@ -1071,6 +1069,11 @@ Playlist and Queue Management:
Thread.sleep(250) Thread.sleep(250)
break } } break } }
private String invalidOptionsErr(String commandName) {
err "Invalid options to the ${cmdStyle}${commandName}${normalStyle}" +
" command. Use ${cmdStyle}help ${commandName}${normalStyle} to " +
"see a list of valid options." }
private void playing(def player) { private void playing(def player) {
try { try {
def mediaFiles = library.getMediaFilesWhere(playlistId: playQueue.id) def mediaFiles = library.getMediaFilesWhere(playlistId: playQueue.id)