« get me outta code hell

upd8: be more reasonable about requiring a build mode - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-05-29 18:35:04 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-05-29 19:40:10 -0300
commitd522ee47e95774453e6c5cffe821608e74a090ce (patch)
tree2d8672444af9b680b99258a3218c792c878c7faf
parentcbc808e6254d2e4a7b134e723d3fce701da6dd6d (diff)
upd8: be more reasonable about requiring a build mode
-rwxr-xr-xsrc/upd8.js44
1 files changed, 31 insertions, 13 deletions
diff --git a/src/upd8.js b/src/upd8.js
index c18a0c54..a5fb8ced 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -423,6 +423,37 @@ async function main() {
     ...buildOptions,
   });
 
+  // Most of the time we'll need a build mode specified to do anything useful,
+  // but a few options make it OK to go ahead without (i.e, ones which never
+  // advance to the build). Note that we can only identify this after loading
+  // all options.
+
+  const buildlessOptions = [
+    'help',
+    'migrate-thumbs',
+    'no-build',
+    'thumbs-only',
+  ];
+
+  const buildModeRequired =
+    buildlessOptions.every(option => !cliOptions[option]);
+
+  // If we're going to require a build mode and none is specified,
+  // exit and show what to do.
+
+  if (buildModeRequired && !selectedBuildMode) {
+    showHelpForOptions({
+      heading: `Please specify a build mode:`,
+      options: buildModeFlagOptions,
+    });
+
+    console.log(
+      `(Use ${colors.bright('--help')} for general info and all options, or specify\n` +
+      ` a build mode alongside ${colors.bright('--help')} for that mode's options!`);
+
+    return false;
+  }
+
   if (cliOptions['help']) {
     console.log(
       colors.bright(`hsmusic (aka. Homestuck Music Wiki, HSMusic Wiki)\n`) +
@@ -484,19 +515,6 @@ async function main() {
     return true;
   }
 
-  // At this point we need to have a build mode to do anything useful, so exit
-  // and show what to do, if none was specified.
-  if (!selectedBuildMode) {
-    showHelpForOptions({
-      heading: `Please specify a build mode:`,
-      options: buildModeFlagOptions,
-    });
-    console.log(
-      `(Use ${colors.bright('--help')} for general info and all options, or specify\n` +
-      ` a build mode alongside ${colors.bright('--help')} for that mode's options!`);
-    return false;
-  }
-
   const dataPath = cliOptions['data-path'] || process.env.HSMUSIC_DATA;
   const mediaPath = cliOptions['media-path'] || process.env.HSMUSIC_MEDIA;
   const wikiCachePath = cliOptions['cache-path'] || process.env.HSMUSIC_CACHE;