« get me outta code hell

Error on unknown CLI arguments - 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>2023-01-16 18:14:13 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-01-16 18:14:13 -0400
commitacecaa1ecd52af8b028a671b8933c47c8018d4ec (patch)
tree4deac4795579e9862f8c44740a1b9f91ac46865c
parent380672db7375ab93c5ca4ef4a2fc2a71e18d92fa (diff)
Error on unknown CLI arguments
-rwxr-xr-xsrc/upd8.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/upd8.js b/src/upd8.js
index 21413a17..cb6c559a 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -101,10 +101,12 @@ async function main() {
 
   const selectedBuildModeFlags = Object.keys(
     await parseOptions(process.argv.slice(2), {
+      // Ignore unknown options for now - we'll handle and error them later.
       [parseOptions.handleUnknown]: () => {},
 
-      ...Object.fromEntries(Object.keys(buildModes)
-        .map((key) => [key, {type: 'flag'}])),
+      ...Object.fromEntries(
+        Object.keys(buildModes)
+          .map((key) => [key, {type: 'flag'}])),
     }));
 
   let selectedBuildModeFlag;
@@ -130,6 +132,13 @@ async function main() {
   };
 
   const cliOptions = await parseOptions(process.argv.slice(2), {
+    // We don't want to error when we receive these options, so specify them
+    // here, even though we won't be doing anything with them later.
+    // (This is a bit of a hack.)
+    ...Object.fromEntries(
+      Object.keys(buildModes)
+        .map((key) => [key, {type: 'flag'}])),
+
     ...selectedBuildMode.getCLIOptions(),
 
     // Data files for the site, including flash, artist, and al8um data,
@@ -217,8 +226,6 @@ async function main() {
     'precache-data': {
       type: 'flag',
     },
-
-    [parseOptions.handleUnknown]: () => {},
   });
 
   const dataPath = cliOptions['data-path'] || process.env.HSMUSIC_DATA;