From 580b6487e69db4dd9915c217399d641f38d341e6 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sat, 1 Jun 2024 22:23:53 -0700 Subject: [PATCH] Add showArgs flag to explicitly print input arguments --- index.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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); } } -- 2.47.3