« get me outta code hell

http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/play.js')
-rwxr-xr-xsrc/play.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/play.js b/src/play.js
index 8b051ac..6061d09 100755
--- a/src/play.js
+++ b/src/play.js
@@ -14,7 +14,7 @@ const processSmartPlaylist = require('./smart-playlist')
 
 const {
   filterPlaylistByPathString, removeGroupByPathString, getPlaylistTreeString,
-  updatePlaylistFormat
+  updatePlaylistFormat, collapseGrouplike
 } = require('./playlist-utils')
 
 const readFile = promisify(fs.readFile)
@@ -300,6 +300,19 @@ async function main(args) {
     'r': util => util.alias('-remove'),
     'x': util => util.alias('-remove'),
 
+    '-collapse-groups': function() {
+      // --collapse-groups  (alias: --collapse)
+      // Collapses groups in the active playlist so that there is only one
+      // level of sub-groups. Handy for shuffling the order groups play in;
+      // try `--collapse-groups --sort shuffle-groups`.
+
+      requiresOpenPlaylist()
+
+      activePlaylist = updatePlaylistFormat(collapseGrouplike(activePlaylist))
+    },
+
+    '-collapse': util => util.alias('-collapse-groups'),
+
     '-list-groups': function(util) {
       // --list-groups  (alias: -l, --list)
       // Lists all groups in the playlist.