How to use the commander.output function in commander

To help you get started, we’ve selected a few commander examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spaceraccoon / npm-scan / lib / scan.js View on Github external
resultsArr = resultsArr.concat(manifestScan(packagesInfo[i].name, packagesInfo[i].path, heuristics.manifest))
  }

  resultsArr = await Promise.all(resultsArr)
  resultsArr = resultsArr.filter(v => v !== null)

  // remap results to object
  let resultsObj = {}
  let packageKey
  for (let i = 0; i < packagesLength; i++) {
    packageKey = `${packagesInfo[i].name}@${packagesInfo[i].version}`
    resultsObj[packageKey] = resultsArr.filter(v => v.packageName === packagesInfo[i].name)
    resultsObj[packageKey].map(v => delete v.packageName)
  }

  if (program.output) {
    writeResults(resultsObj, program.output)
  } else {
    printResults(resultsObj, program.verbose)
  }

  return resultsObj
}
github bitpay / node-bitpay-client / bin / bitpay.js View on Github external
getPassword(function(keypassword) {
        console.log('Generating keys...');

        var sin    = bitauth.generateSin();
        var secret = bitauth.encrypt(keypassword, sin.priv);
        var query  = qs.stringify({
          label: 'node-bitpay-client-' + require('os').hostname(),
          id: sin.sin,
          facade: 'merchant'
        });

        fs.writeFileSync(bitpay.output + '/api.key', secret);
        fs.writeFileSync(bitpay.output + '/api.pub' , sin.sin);

        console.log('Keys saved to:', bitpay.output, '\n');
        console.log('Your client identifier is:', sin.sin, '\n\n');

        process.exit();
      });
    };
github skratchdot / color-matrix / lib / cli.js View on Github external
.map(parseFloat);
	} else {
		program.value = parseFloat(program.value);
	}
}

if (program.input) {
	program.input = path.resolve(program.input);
	if (!fs.existsSync(program.input)) {
		console.error('The input file "' + program.input + '" does not exist.');
		process.exit();
	} else if (typeof program.output !== 'string' || program.output.length <= 0) {
		console.error('Must specify an output file when specifying an input file.');
		process.exit();
	} else {
		program.output = path.resolve(program.output);
		Caman.Filter.register('colorMatrix', function () {
			this.process('colorMatrix', function (rgba) {
				var res = matrix.transform([rgba.r, rgba.g, rgba.b, rgba.a], program.filter, program.value);
				rgba.r = res[0];
				rgba.g = res[1];
				rgba.b = res[2];
				rgba.a = res[3];
				return rgba;
			});
		});
		console.log('writing file: ' + program.output);
		new Caman([program.input, function () {
			this.colorMatrix();
			this.render(function () {
				this.save(program.output);
			});
github mtmacdonald / docgen / source / options.js View on Github external
this.load = function () {
		program
		  .version('2.0.0')
		  .option('-i, --input [type]', 'path to input directory (default: pwd)', 'pwd')
		  .option('-o, --output [type]', 'path to output directory (default: ./outputs)', './output')
		  .option('-H, --homepage [type]', 'set the homepage filename (default: index.html)', 'index.html')
		  .option('-p, --pagetoc [type]', 'include a page table of contents (default: true)', true)
		  .option('-w, --warnings [type]', 'suppress internet explorer warnings (default: false)', false)
		  .parse(process.argv);

		console.log(program.input);
		console.log(program.output);
		console.log(program.homepage);
		console.log(program.pagetoc);
	    console.log(program.warnings);
	}
}
github BYVoid / continuation / lib / cli.js View on Github external
var outputCode = function (originalFilename, code) {
  if (commander.output) {
    var filename = commander.output;
    if (options.sourceMap) {
      var sourceMapFilename = filename + '.map';
      var sourceMap = continuation.getSourceMap(
        path.basename(filename),
        [path.basename(originalFilename)]
      );
      code += '\n//@ sourceMappingURL=' + path.basename(sourceMapFilename);
      fs.writeFileSync(sourceMapFilename, sourceMap);
    }
    fs.writeFileSync(filename, code);
  } else {
    console.log(code);
  }
};
github rolling-scopes / rsschool-app / tools / rs-checkist / src / helpers / command-flow.ts View on Github external
const results = await getDataFromService(config, students);

  const scores = await prepareScores(config, results, altTaskName);

  if (commander.errorLogPath) {
    const filename = `${commander.errorLogPath}errors-`;

    console.log('\nStage: writing logs to file');
    writeStudentResults(service, logger.logs, filename, 'json');
  }

  await callback(scores);

  if (commander.output) {
    console.log('\nStage: writing to file');
    writeStudentResults(service, scores, commander.output, 'json');
  }

  console.log('\nJob\'s done!');
};
github wojtkowiak / meteor-desktop / lib / bin / cli.js View on Github external
function meteorDesktopFactory(ddpUrl, production = false) {
    info(`METEOR-DESKTOP v${require('./../../package.json').version}\n`);

    verifyArgsSyntax();

    const input = process.cwd();

    if (!isMeteorApp(input)) {
        error(`not in a meteor app dir\n ${input}`);
        process.exit();
    }

    if (!program.output) {
        program.output = input;
    }

    if (production && !program.production) {
        info('package/build-installer implies setting --production, setting it for you');
    }

    if (!program.buildMeteor) {
        program.port = program.port || 3000;
        info(`REMINDER: your Meteor project should be running now on port ${program.port}\n`);
    }

    if (program.prodDebug) {
        info('!! WARNING: You are adding devTools to a production build !!\n');
    }

    const options = {
github compodoc / ngd / src / modules / cli / dist / cli.js View on Github external
}
                        });
                        return results;
                    };
                    files = walk_1(cwd || '.');
                }
            }
        }
        else {
            outputHelp();
        }
        if (path.isAbsolute(program.output)) {
            program.output = program.output;
        }
        else {
            program.output = path.resolve(process.cwd(), program.output);
        }
        var compiler = new ngd_compiler_1.Compiler(files, {
            tsconfigDirectory: cwd,
            silent: program.silent
        });
        var deps = compiler.getDependencies();
        if (deps.length <= 0) {
            ngd_core_1.logger.warn('no deps', 'May be you should consider providing another entry file. See -h');
            ngd_core_1.logger.info('Done');
            process.exit(0);
        }
        var engine = new ngd_transformer_1.DotEngine({
            output: program.output,
            displayLegend: program.displayLegend,
            outputFormats: program.outputFormats.split(',')
        });
github jgraph / drawio / src / main / webapp / electron.js View on Github external
if (program.export)
	{
    	var dummyWin = new BrowserWindow({
			show : false
		});
    	
    	windowsRegistry.push(dummyWin);
    	
    	try
    	{
	    	//Prepare arguments and confirm it's valid
	    	var format = null;
	    	var outType = null;
	    	
	    	//Format & Output
	    	if (program.output)
			{
	    		try
	    		{
	    			var outStat = fs.statSync(program.output);
	    			
	    			if (outStat.isDirectory())
					{
	    				outType = {isDir: true};
					}
	    			else //If we can get file stat, then it exists
					{
	    				throw 'Error: Output file already exists';
					}
	    		}
	    		catch(e) //on error, file doesn't exist and it is not a dir
	    		{
github SuperMarcus / pgoogle / cli.js View on Github external
.option('-f, --false', "specify with --answer, answer all the questions with no")
    .option('-s, --syn', "substitute words with synonyms")
    .option('-n, --num [number]', "number of sentences to include in the output")
    .parse(process.argv);

const io = {
    in: process.stdin,
    out: process.stderr,
    store: process.stdout
};
const rl = Readline.createInterface({
    input: io.in,
    output: io.out
});

if (cli.output && cli.output !== '-'){
    io.store = fs.createWriteStream(cli.output);
}

const ioCleanup = () => {
    if (cli.output && cli.output !== '-')
        io.store.close();
    rl.close();
};

const ioWriteStore = (data) => (new Promise(res => io.store.write(data, 'utf8', res)));

//Two step process!!
const ask = async (question, type, colorizer) => {
    let typeHinter = (
        type === 'boolean' ? " [yes|no]" :
        type === 'number' ? " [number]" :