Added and commands to CLI.
This commit is contained in:
parent
ffcfc7bc77
commit
4507c6b664
@ -12,7 +12,7 @@ allprojects {
|
||||
}
|
||||
|
||||
group = 'com.jdbernard'
|
||||
version = '0.1.0'
|
||||
version = '0.1.1'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
|
@ -28,7 +28,7 @@ import static com.jdbernard.wdiwtlt.cli.CliErr.*
|
||||
|
||||
public class CommandLineInterface {
|
||||
|
||||
public static final VERSION = "ALPHA"
|
||||
public static final VERSION = "0.1.1"
|
||||
|
||||
public static final def DOC = """\
|
||||
wdiwtlt v$VERSION
|
||||
@ -125,6 +125,7 @@ Configuration:
|
||||
private ScrollText status = new ScrollText(maxWidth: displayWidth)
|
||||
private Date dismissMsgDate = new Date()
|
||||
private SimpleDateFormat sdf = new SimpleDateFormat('EEE-HH-SSS')
|
||||
private Random rand = new Random()
|
||||
|
||||
/// Current play queue and selection data
|
||||
List<Model> currentSelection = []
|
||||
@ -503,6 +504,7 @@ Configuration:
|
||||
Class modelClass
|
||||
|
||||
switch (options) {
|
||||
case ~/selection/: return selection;
|
||||
case ~/playing ($selectableModels)s?/:
|
||||
if (!curMediaFile) err "No media is currently playing."
|
||||
|
||||
@ -513,10 +515,29 @@ Configuration:
|
||||
else return library.getWhere(modelClass,
|
||||
[mediaFileId: curMediaFile.id])
|
||||
|
||||
/* TODO
|
||||
case ~/files tagged as((\s\w+)+?) and not as((\s\w+)+)/:
|
||||
excludedTags = lastMatcher[0][3].split(/\s/)
|
||||
*/
|
||||
case ~/(\d+ )?random ($selectableModels)s?( from (.+$))?/:
|
||||
modelClass = modelClasses[Matcher.lastMatcher[0][2]]
|
||||
def sourceCriteria = Matcher.lastMatcher[0][4]?.trim()
|
||||
int count = (Matcher.lastMatcher[0][1] ?: 1) as int
|
||||
|
||||
def source
|
||||
if (sourceCriteria) {
|
||||
source = select(sourceCriteria, selection)
|
||||
if (modelClass != source[0].class) {
|
||||
source = source.collectMany { library.getWhere(modelClass,
|
||||
[(idKeyFor(source[0].class)): it.id]) }
|
||||
.findAll().unique() } }
|
||||
|
||||
else source = library.getAll(modelClass);
|
||||
|
||||
if (source.size() < count)
|
||||
err "There are not ${count} ${toEnglish(modelClass)}s to select."
|
||||
|
||||
def selected = []
|
||||
(0..<count).each {
|
||||
selected << source.remove(rand.nextInt(source.size())) }
|
||||
|
||||
return selected
|
||||
|
||||
case ~/selected ($selectableModels)s?/:
|
||||
|
||||
@ -543,6 +564,18 @@ Configuration:
|
||||
// TODO
|
||||
err "select <thing> where ... is not yet implemented."
|
||||
|
||||
case ~/($selectableModels)s? from (.+)/:
|
||||
modelClass = modelClasses[Matcher.lastMatcher[0][1]]
|
||||
def sourceCriteria = Matcher.lastMatcher[0][2].trim()
|
||||
def models = select(sourceCriteria, selection)
|
||||
|
||||
if (modelClass != models[0].class) {
|
||||
models = models.collectMany { library.getWhere(modelClass,
|
||||
[(idKeyFor(models[0].class)): it.id]) }
|
||||
.findAll().unique() }
|
||||
|
||||
return models;
|
||||
|
||||
case ~/($selectableModels)s((\s\d+)+)/:
|
||||
modelClass = modelClasses[Matcher.lastMatcher[0][1]]
|
||||
return Matcher.lastMatcher[0][2].split(/\s/)
|
||||
@ -1038,10 +1071,18 @@ ${cmdStyle}select playing { album | artist | file | playlist | tag }${normalStyl
|
||||
this selects items that are associated with the currently playing media
|
||||
file.
|
||||
|
||||
${cmdStyle}queued { albums | artists | files | playlists | tags }${normalStyle}
|
||||
${cmdStyle}select queued { albums | artists | files | playlists | tags }${normalStyle}
|
||||
|
||||
Select the items currently in the queue.
|
||||
|
||||
${cmdStyle}select <count> random {albums | artists | files | playlists | tags }${normalStyle}
|
||||
|
||||
Select one or more items randomly.
|
||||
|
||||
${cmdStyle}select <count> random {albums | artists | files | playlists | tags } from <select-criteria>${normalStyle}
|
||||
|
||||
Make a selection, then select one or more items randomly from it.
|
||||
|
||||
${cmdStyle}select selected { album | artist | file | playlist | tag }${normalStyle}
|
||||
|
||||
Select the items associated with the current selection buffer into the
|
||||
|
Loading…
Reference in New Issue
Block a user