« get me outta code hell

http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--man/http-music.15
-rwxr-xr-xsrc/play.js14
-rw-r--r--todo.txt1
3 files changed, 20 insertions, 0 deletions
diff --git a/man/http-music.1 b/man/http-music.1
index 4a7e824..625b174 100644
--- a/man/http-music.1
+++ b/man/http-music.1
@@ -34,6 +34,11 @@ Sets the downloader type used for actually retrieving track files.
 The default is \fBhttp\fR.
 
 .TP
+.BR \-h ", " \-? ", " \-\-help
+Presents a help message, directing the user to the \fBman\fR page.
+If this is the last option used, nothing plays (see \fB\-\-play\fR).
+
+.TP
 .BR \-k ", " \-\-keep " \fIgroupPath\fR"
 Keeps a group by adding it from the source playlist.
 This is usually useful after clearing the active playlist (\fB\-\-clear\fR); it can also be used to keep a sub-group after removing an entire parent group, e.g. \fB-r foo -k foo/baz\fR.
diff --git a/src/play.js b/src/play.js
index 7023d9f..fee1b79 100755
--- a/src/play.js
+++ b/src/play.js
@@ -48,6 +48,20 @@ setupDefaultPlaylist('./playlist.json')
     }
 
     await processArgv(process.argv, {
+      '-help': function(util) {
+        // --help  (alias: -h, -?)
+        // Presents a help message.
+
+        console.log('http-music\nTry man http-music!')
+
+        if (util.index === util.argv.length - 1) {
+          shouldPlay = false
+        }
+      },
+
+      'h': util => util.alias('-help'),
+      '?': util => util.alias('-help'),
+
       '-open': async function(util) {
         // --open <file>  (alias: -o)
         // Opens a separate playlist file.
diff --git a/todo.txt b/todo.txt
index c50bff5..4127bcc 100644
--- a/todo.txt
+++ b/todo.txt
@@ -91,3 +91,4 @@ TODO: Make a way to skip tracks while playing. Currently the only way is to
       forces the user to wait for another one to be downloaded.
 
 TODO: Make a --help/-h/-? option that directs helpless users to the man page.
+      (Done!)