]> git.ardis.lu - transcriber/commitdiff
Add showArgs flag to explicitly print input arguments
authorArdis Lu <ardisglu@gmail.com>
Sun, 2 Jun 2024 05:23:53 +0000 (22:23 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sun, 2 Jun 2024 05:23:53 +0000 (22:23 -0700)
index.ts

index d61c8cf025f8cf9b19754863796edd417a003f54..1d8b4bb6b45b45e83489e74970163e99e81459fe 100644 (file)
--- a/index.ts
+++ b/index.ts
@@ -8,6 +8,10 @@ const program = new Command()
   .requiredOption(
     "-i, --input <string>",
     "JSON file with command and arguments to execute",
+  )
+  .option(
+    "--show-args",
+    "log input arguments along with the input command",
   );
 program.parse();
 const options = program.opts();
@@ -45,16 +49,20 @@ const c = Object.defineProperty([command], "raw", {
 }) as unknown as TemplateStringsArray;
 
 if (args === undefined) {
-  console.log(`$ ${command}`);
+  console.log(`\n$ ${command}`);
   await $(c);
 } else {
   const runs = getCombinations(args);
-  for (const options of runs) {
+  for (const inputArgs of runs) {
     let input = command;
-    for (const [key, value] of Object.entries(options)) {
+    for (const [key, value] of Object.entries(inputArgs)) {
       input = input.replaceAll(`$${key}`, value);
     }
-    console.log(`$ ${input}`);
-    await $(c).env(options);
+    console.log(`\n$ ${input}`);
+    if (options.showArgs) {
+      console.table(inputArgs);
+      console.log("-------");
+    }
+    await $(c).env(inputArgs);
   }
 }
This page took 0.035566 seconds and 4 git commands to generate.