« get me outta code hell

boot directly into REPL with --repl - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/upd8.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-03-04 18:00:10 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-03-04 18:00:10 -0400
commit06e1503a921ca28c4d4f994ee46a3044acfb3a32 (patch)
treea6d150ce782582b963850a4e6b2598f4bdd5d0d9 /src/upd8.js
parent79b233cab5853b50717ffb281247485e26101ef0 (diff)
boot directly into REPL with --repl
Diffstat (limited to 'src/upd8.js')
-rwxr-xr-xsrc/upd8.js33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/upd8.js b/src/upd8.js
index 2b4fb5f6..9fff67cc 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -41,6 +41,8 @@ import genThumbs, {
   defaultMagickThreads,
   isThumb,
 } from './gen-thumbs.js';
+
+import bootRepl from './repl.js';
 import {listingSpec, listingTargetSpec} from './listing-spec.js';
 import urlSpec from './url-spec.js';
 
@@ -126,7 +128,6 @@ async function main() {
   if (empty(selectedBuildModeFlags)) {
     selectedBuildModeFlag = 'static-build';
     usingDefaultBuildMode = true;
-    logInfo`No build mode specified, using default: ${selectedBuildModeFlag}`;
   } else if (selectedBuildModeFlags.length > 1) {
     logError`Building multiple modes (${selectedBuildModeFlags.join(', ')}) at once not supported.`;
     logError`Please specify a maximum of one build mode.`;
@@ -134,7 +135,6 @@ async function main() {
   } else {
     selectedBuildModeFlag = selectedBuildModeFlags[0];
     usingDefaultBuildMode = false;
-    logInfo`Using specified build mode: ${selectedBuildModeFlag}`;
   }
 
   const selectedBuildMode = buildModes[selectedBuildModeFlag];
@@ -184,6 +184,16 @@ async function main() {
       type: 'value',
     },
 
+    'repl': {
+      help: `Boot into the HSMusic REPL for command-line interactive access to data objects`,
+      type: 'flag',
+    },
+
+    'no-repl-history': {
+      help: `Disable locally logging commands entered into the REPL in your home directory`,
+      type: 'flag',
+    },
+
     // Thum8nail gener8tion is *usually* something you want, 8ut it can 8e
     // kinda a pain to run every time, since it does necessit8te reading
     // every media file at run time. Pass this to skip it.
@@ -367,6 +377,9 @@ async function main() {
   const clearThumbsFlag = cliOptions['clear-thumbs'] ?? false;
   const noBuild = cliOptions['no-build'] ?? false;
 
+  const replFlag = cliOptions['repl'] ?? false;
+  const disableReplHistory = cliOptions['no-repl-history'] ?? false;
+
   const showAggregateTraces = cliOptions['show-traces'] ?? false;
 
   const precacheData = cliOptions['precache-data'] ?? false;
@@ -394,6 +407,16 @@ async function main() {
     }
   }
 
+  if (replFlag) {
+    return bootRepl({
+      dataPath,
+      mediaPath,
+
+      disableHistory: disableReplHistory,
+      showTraces: showAggregateTraces,
+    });
+  }
+
   const niceShowAggregate = (error, ...opts) => {
     showAggregate(error, {
       showTraces: showAggregateTraces,
@@ -431,6 +454,12 @@ async function main() {
     if (thumbsOnly) return;
   }
 
+  if (usingDefaultBuildMode) {
+    logInfo`No build mode specified, using default: ${selectedBuildModeFlag}`;
+  } else {
+    logInfo`Using specified build mode: ${selectedBuildModeFlag}`;
+  }
+
   if (showInvalidPropertyAccesses) {
     CacheableObject.DEBUG_SLOW_TRACK_INVALID_PROPERTIES = true;
   }