From: Ardis Lu Date: Sun, 2 Jun 2024 05:23:53 +0000 (-0700) Subject: Add showArgs flag to explicitly print input arguments X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=580b6487e69db4dd9915c217399d641f38d341e6;p=transcriber Add showArgs flag to explicitly print input arguments --- diff --git a/index.ts b/index.ts index d61c8cf..1d8b4bb 100644 --- a/index.ts +++ b/index.ts @@ -8,6 +8,10 @@ const program = new Command() .requiredOption( "-i, --input ", "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); } }