« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/cli.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli.js')
-rw-r--r--src/cli.js21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/cli.js b/src/cli.js
index ec72a625..52ac9f9c 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -231,18 +231,29 @@ export function showHelpForOptions({
   options,
   indentWrap,
   sort = entries => entries,
+  silentIfNoOptions = false,
 }) {
-  if (heading) {
-    console.log(colors.bright(heading));
-  }
-
   const sortedOptions =
     sort(
       Object.entries(options)
         .map(([name, descriptor]) => ({name, descriptor})));
 
+  if (!sortedOptions.length && silentIfNoOptions) return;
+
+  if (heading) {
+    console.log(colors.bright(heading));
+  }
+
   if (!sortedOptions.length) {
-    console.log(`(No options available)`)
+    if (heading) {
+      console.log(``);
+      console.log(`  (No options available)`);
+      console.log(``);
+    } else {
+      console.log(`(No options available)`);
+    }
+
+    return;
   }
 
   let justInsertedPaddingLine = false;