« get me outta code hell

Merge branch 'master' of https://github.com/liam4/http-music - http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src/cli.js
diff options
context:
space:
mode:
authorFlorrie <towerofni@gmail.com>2017-08-03 03:20:23 +0400
committerFlorrie <towerofni@gmail.com>2017-08-03 03:20:23 +0400
commit63ee18f61991cfcd10e42871d57eccd53fa51828 (patch)
treeb07bbe3aa8b4358a77758783638b447465a850fe /src/cli.js
parentb94845e008931bfaee56b91db1f892af7a6d339f (diff)
parent70462b74635da8eb92c10d51d1a8a1fe06ceb9f1 (diff)
Merge branch 'master' of https://github.com/liam4/http-music
Diffstat (limited to 'src/cli.js')
-rwxr-xr-xsrc/cli.js29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/cli.js b/src/cli.js
index 4bc64ab..9b21395 100755
--- a/src/cli.js
+++ b/src/cli.js
@@ -4,6 +4,8 @@
 // maxlistenersexceededwarning.
 process.on('warning', e => console.warn(e.stack))
 
+const { getCrawlerByName } = require('./crawlers')
+
 async function main(args) {
   let script
 
@@ -13,18 +15,21 @@ async function main(args) {
     return
   }
 
-  switch (args[0]) {
-    case 'play': script = require('./play'); break
-    case 'crawl-http': script = require('./crawl-http'); break
-    case 'crawl-local': script = require('./crawl-local'); break
-    case 'crawl-itunes': script = require('./crawl-itunes'); break
-    case 'crawl-youtube': script = require('./crawl-youtube'); break
-    case 'download-playlist': script = require('./download-playlist'); break
-
-    default:
-      console.error(`Invalid command "${args[0]}" provided.`)
-      console.error("Try 'man http-music'?")
-      return
+  const module = getCrawlerByName(args[0])
+
+  if (module) {
+    script = module.main
+  } else {
+    switch (args[0]) {
+      case 'play': script = require('./play'); break
+      case 'download-playlist': script = require('./download-playlist'); break
+      case 'smart-playlist': script = require('./smart-playlist'); break
+
+      default:
+        console.error(`Invalid command "${args[0]}" provided.`)
+        console.error("Try 'man http-music'?")
+        return
+    }
   }
 
   await script(args.slice(1))