From 36783812d77132e2cd0e5c73f54a2de18d2dbdc0 Mon Sep 17 00:00:00 2001 From: blurry-x-face Date: Thu, 20 Feb 2020 16:22:55 +0530 Subject: [PATCH 1/3] fix cli input method --- index.js | 5 ++++- src/CliUtils.js | 3 ++- src/cli/sequencerSteps.js | 29 ++++++++--------------------- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/index.js b/index.js index 2427eda71a..46e8ad205a 100755 --- a/index.js +++ b/index.js @@ -33,6 +33,9 @@ else if (program.installModule) installModule(program, sequencer); else { // Parse step into an array to allow for multiple steps. if (!program.step) exit('No steps passed'); + + program.steps = sequencer.stringToJSON(program.step); + program.step = program.step.split(' '); // User must input an image. @@ -44,7 +47,7 @@ else { }); // User must input a step. If steps exist, check that every step is a valid step. - if (!program.step || !(utils.validateSteps(program.step, sequencer))) + if (!program.steps || !(utils.validateSteps(program.steps, sequencer))) exit('Please ensure all steps are valid.'); // If there's no user defined output directory, select a default directory. diff --git a/src/CliUtils.js b/src/CliUtils.js index bcf1fe3d09..df2f0f7228 100644 --- a/src/CliUtils.js +++ b/src/CliUtils.js @@ -19,8 +19,9 @@ function validateSteps(steps, sequencer) { // Assume all are valid in the beginning. var valid = true; steps.forEach(function(step) { + console.log(step.name); // If any step in the array is not valid (not a property of modulesInfo), set valid to false. - if (!sequencer.modulesInfo().hasOwnProperty(step)) { + if (!sequencer.modulesInfo().hasOwnProperty(step.name)) { valid = false; } }); diff --git a/src/cli/sequencerSteps.js b/src/cli/sequencerSteps.js index 3603bb32bd..2361bfb4c8 100644 --- a/src/cli/sequencerSteps.js +++ b/src/cli/sequencerSteps.js @@ -9,13 +9,13 @@ module.exports = function (program, sequencer, outputFilename) { if (program.basic) console.log('Basic mode is enabled, outputting only final image'); - // Iterate through the steps and retrieve their inputs. - program.step.forEach(function(step) { - var options = Object.assign({}, sequencer.modulesInfo(step).inputs); + + program.steps.forEach(function(step) { + var options = Object.assign({}, sequencer.modulesInfo(step.name).inputs); // If inputs exists, print to console. if (Object.keys(options).length) { - console.log('[' + step + ']: Inputs'); + console.log('[' + step.name + ']: Inputs'); } // If inputs exists, print them out with descriptions. @@ -23,30 +23,17 @@ module.exports = function (program, sequencer, outputFilename) { // The array below creates a variable number of spaces. This is done with (length + 1). // The extra 4 that makes it (length + 5) is to account for the []: characters console.log( - new Array(step.length + 5).join(' ') + + new Array(step.name.length + 5).join(' ') + input + ': ' + options[input].desc ); }); - if (program.config) { - try { - var config = JSON.parse(program.config); - console.log('The parsed options object: ', config); - } catch (e) { - console.error( - '\x1b[31m%s\x1b[0m', - 'Options(Config) is not a not valid JSON Fallback activate' - ); - program.config = false; - console.log(e); - } - } - if (program.config && utils.validateConfig(config, options)) { + if (Object.keys(step.options).length > 0) { console.log('Now using Options object'); Object.keys(options).forEach(function(input) { - options[input] = config[input]; + options[input] = step.options[input]; }); } else { // If inputs exist, iterate through them and prompt for values. @@ -66,7 +53,7 @@ module.exports = function (program, sequencer, outputFilename) { }); } // Add the step and its inputs to the sequencer. - sequencer.addSteps(step, options); + sequencer.addSteps(step.name, options); }); var spinnerObj = { succeed: () => { }, stop: () => { } }; From 3e77d6ba1e5146c498b743513d4c2f2b6322642a Mon Sep 17 00:00:00 2001 From: blurry-x-face Date: Thu, 20 Feb 2020 19:32:40 +0530 Subject: [PATCH 2/3] fix cli input --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 46e8ad205a..d9c745c236 100755 --- a/index.js +++ b/index.js @@ -36,6 +36,9 @@ else { program.steps = sequencer.stringToJSON(program.step); + var stepNames = []; + program.step.split(',').forEach(v => stepNames.push(v.split('{')[0])); + program.step = program.step.split(' '); // User must input an image. @@ -60,7 +63,7 @@ else { step.info = sequencer.modulesInfo(step.name); for (var output in step.info.outputs) { - console.log('[' + program.step + ']: ' + output + ' = ' + step[output]); + console.log('[' + stepNames + ']: ' + output + ' = ' + step[output]); } }, notify: function(msg) { From fff6dcd8e3c09da36d9d3d6877e83fefb0050419 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Mon, 2 Nov 2020 14:46:13 -0500 Subject: [PATCH 3/3] remove console.log statement in Update src/CliUtils.js --- src/CliUtils.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/CliUtils.js b/src/CliUtils.js index df2f0f7228..4099c918d5 100644 --- a/src/CliUtils.js +++ b/src/CliUtils.js @@ -19,7 +19,6 @@ function validateSteps(steps, sequencer) { // Assume all are valid in the beginning. var valid = true; steps.forEach(function(step) { - console.log(step.name); // If any step in the array is not valid (not a property of modulesInfo), set valid to false. if (!sequencer.modulesInfo().hasOwnProperty(step.name)) { valid = false; @@ -56,4 +55,4 @@ module.exports = exports = { makedir: makedir, validateSteps: validateSteps, validateConfig: validateConfig -}; \ No newline at end of file +};