diff options
author | Florrie <towerofnix@gmail.com> | 2017-08-11 10:06:04 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2017-08-11 10:06:04 -0300 |
commit | 6d063af2b57841dce30ddb07bf60ce828d737697 (patch) | |
tree | 766a51d636dd43c5894c5bb28667fb607bb557fe /src/play.js | |
parent | 9fa3021cd8424f2e82a6b48aaf85db6fd5d27659 (diff) |
Completely re-implement pickers
Diffstat (limited to 'src/play.js')
-rwxr-xr-x | src/play.js | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/play.js b/src/play.js index 50be20e..408b79c 100755 --- a/src/play.js +++ b/src/play.js @@ -7,7 +7,7 @@ const clone = require('clone') const fs = require('fs') const fetch = require('node-fetch') const commandExists = require('./command-exists') -const { byName: pickersByName } = require('./pickers') +const makePicker = require('./pickers') const startLoopPlay = require('./loop-play') const processArgv = require('./process-argv') const processSmartPlaylist = require('./smart-playlist') @@ -55,7 +55,8 @@ async function main(args) { let sourcePlaylist = null let activePlaylist = null - let pickerType = 'shuffle' + let pickerSortMode = 'shuffle' + let pickerLoopMode = 'loop-regenerate' let playerCommand = await determineDefaultPlayer() let playOpts = [] @@ -276,15 +277,31 @@ async function main(args) { 'np': util => util.alias('-no-play'), - '-picker': function(util) { - // --picker <picker type> (alias: --selector) - // Selects the mode that the song to play is picked. + '-sort-mode': function(util) { + // --sort-mode <mode> (alias: --sort) + // Sets the mode by which the playback order list is sorted. + // Valid options include 'order', 'shuffle', and 'shuffle-top-level' + // (which has an alias 'shuffle-groups'). // See pickers.js. - pickerType = util.nextArg() + pickerSortMode = util.nextArg() }, - '-selector': util => util.alias('-picker'), + '-sort': util => util.alias('-sort-mode'), + + '-loop-mode': function(util) { + // --loop-mode <mode> (alias: --loop) + // Sets the mode by which the playback order list is looped (typically, + // what happens when the picker's index counter gets to the end of the + // list). + // Valid options include 'no-loop', 'loop-same-order' (or 'loop'), + // 'loop-regenerate', and 'pick-random'. + // See pickers.js. + + pickerLoopMode = util.nextArg() + }, + + '-loop': util => util.alias('-loop-mode'), '-player': function(util) { // --player <player> @@ -307,14 +324,9 @@ async function main(args) { } if (willPlay || (willPlay === null && shouldPlay)) { - if (!Object.keys(pickersByName).includes(pickerType)) { - console.error("Invalid picker type: " + pickerType) - return - } - - console.log(`Using ${pickerType} picker.`) + console.log(`Using sort: ${pickerSortMode} and loop: ${pickerLoopMode}.`) - const picker = pickersByName[pickerType](activePlaylist) + const picker = makePicker(activePlaylist, pickerSortMode, pickerLoopMode) console.log(`Using ${playerCommand} player.`) |