diff options
author | Florrie <towerofnix@gmail.com> | 2017-11-12 11:21:21 -0400 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2017-11-12 11:21:54 -0400 |
commit | 8243539e77cbf2ce4a64a7ab1736526f7a66b000 (patch) | |
tree | bc3922d9e3d31d69a0e20d34371c1a117de86474 /src/play.js | |
parent | 8da8488a943362c3f7bc222c3a26640b8591cb04 (diff) |
Add --show-keybindings and make a string dynamic
"(Press I for track info!)" now displays the appropriate keybinding, rather than always showing "I". Also made the keybinder handler function async; it now waits for its given commands to finish. This doesn't particularly change anything but it Makes Sense.
Diffstat (limited to 'src/play.js')
-rwxr-xr-x | src/play.js | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/play.js b/src/play.js index 2a5cbdd..ff9e76a 100755 --- a/src/play.js +++ b/src/play.js @@ -11,7 +11,6 @@ const commandExists = require('./command-exists') const startLoopPlay = require('./loop-play') const processArgv = require('./process-argv') const promisifyProcess = require('./promisify-process') -const { compileKeybindings } = require('./keybinder') const processSmartPlaylist = require('./smart-playlist') const { @@ -19,6 +18,10 @@ const { updatePlaylistFormat, collapseGrouplike, filterGrouplikeByProperty, isTrack } = require('./playlist-utils') +const { + compileKeybindings, getComboForCommand, stringifyCombo +} = require('./keybinder') + const readFile = promisify(fs.readFile) const writeFile = promisify(fs.writeFile) @@ -401,6 +404,20 @@ async function main(args) { '-list-tracks': util => util.alias('-list-all'), 'L': util => util.alias('-list-all'), + '-list-keybindings': function() { + console.log('Keybindings:') + + for (const [ combo, command, ...args ] of keybindings) { + console.log(`${stringifyCombo(combo)}: ${command}${ + args ? ' ' + args.join(' ') : ''}`) + } + + shouldPlay = false + }, + + '-show-keybindings': util => util.alias('-list-keybindings'), + '-keybindings': util => util.alias('-list-keybindings'), + '-play': function(util) { // --play (alias: -p) // Forces the playlist to actually play. @@ -625,6 +642,12 @@ async function main(args) { console.warn("If you're piping into http-music, this is normal.") } + const trackInfoCombo = stringifyCombo(getComboForCommand( + 'showTrackInfo', keybindings + )) + + const trackInfoString = `(Press ${trackInfoCombo} for track info!)` + const commands = { 'doNothing': function() {}, @@ -662,7 +685,7 @@ async function main(args) { 'skipBack': function() { clearConsoleLine() - console.log("Skipping backwards. (Press I for track info!") + console.log("Skipping backwards.", trackInfoString) playController.skipBack() }, @@ -670,8 +693,7 @@ async function main(args) { 'skipAhead': function() { clearConsoleLine() console.log( - "Skipping the track that's currently playing. " + - "(Press I for track info!)" + "Skipping the track that's currently playing.", trackInfoString ) playController.skip() |