How to use the commander.input 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 T-vK / tvoip / network-stream-test-3.js View on Github external
const package = require('./package.json')

program
  .version(package.version)
  .option('-c, --connect ', 'Connect to a host, (Supports IP:port and hostname:port.)')
  .option('-l, --listen ', 'Automatically accept connections on this port.')
  .option('-i, --input [device-name]', 'Input device, (Leave empty to use the default recording device.)')
  .option('-o, --output [device-name]', 'Output device, (Leave empty to use the default playback device.)')
  .option('-a, --channels [count]', 'Number of channels 1=mono; 2=stereo (Leave empty to use 1.)',1)
  //.option('-s, --speaker-enabled', 'Speaker enabled initially. (true or false)', true)
  //.option('-m, --microphone-enabled', 'Microphone enabled initially. (true or false)', true)
  .parse(process.argv)

console.log('--connect: ' + program.connect)
console.log('--listen: ' + program.listen)
console.log('--input: ' + program.input)
console.log('--output: ' + program.output)

const mode = !program.connect ? 'listen' : 'connect'

let speakerConfig = { // | aplay -D plughw:NVidia,7
    //device: program.output, // -D plughw:NVidia,7
    channels: 2,
    bitDepth: 16,
    sampleRate: 44100,
    signed: true
}
if (program.output)
    speakerConfig.device = program.output

let micConfig = {       // arecord -D hw:0,0 -f S16_LE -r 44100 -c 2
    //device: program.input,    // -D hw:0,0
github Kitware / simput / src / cli / simput-cli.js View on Github external
.option('-c, --compile [directory]', 'Directory to compile files')
  .option('-t, --type [type]', 'Type of input\n')
  .option('-o, --output [directory]', 'Output directory to output to')
  .option('-m, --minify', 'Minify compiled file')

  .parse(process.argv);

// console.log(process.argv);
// console.log(process.argv.slice(2));
if (!process.argv.slice(2).length) {
  program.outputHelp();
  process.exit(0);
}

// input
if (program.input) {
  if (program.output) shell.mkdir('-p', toAbsolutePath(program.output));
  // output optional, default is directory of input file.
  simputConverter(program.input, program.output);
} else if (program.compile) {
  shell.mkdir('-p', toAbsolutePath(program.output));
  let addFunc = null;

  // default type is last part of compile dir
  // default output is compile dir.
  simputCompiler(
    toAbsolutePath(program.compile),
    program.type,
    program.output,
    program.minify,
    addFunc
  );
github Azure / iothub-explorer / iothub-explorer-import-devices.js View on Github external
showDeprecationText('az iot hub device-identity import');

program
  .description('Import devices in bulk into the device identity registry. The input file gets uploaded to a blob and then an import job is started from that blob.')
  .usage('[options] --storage  --output ')
  .option('-i, --input ', 'path to the input file containing device descriptions')
  .option('-o, --output ', 'path indicating where to download the import log file generated by the service (empty in case of success)')
  .option('-s, --storage ', 'Azure blob storage connection string to be used during bulk import')
  .option('-l, --login ', 'use the connection string provided as argument to use to authenticate with your IoT hub')
  .parse(process.argv);

if(!program.storage) inputError('A storage connection string with permissions to create a blob is required.');
if(!program.input) inputError('An input file path is required.');

var inputFile = program.input;
var outputFile = program.output;
var storageConnectionString = program.storage;
var sas = getSas(program.login);

var registry = Registry.fromSharedAccessSignature(sas);
var blobSvc = azureStorage.createBlobService(storageConnectionString);

var startDate = new Date();
var expiryDate = new Date(startDate);
// Use a large interval to account for clock errors and time to run the job.
expiryDate.setMinutes(startDate.getMinutes() + 100);
startDate.setMinutes(startDate.getMinutes() - 100);

var inputSharedAccessPolicy = {
  AccessPolicy: {
    Permissions: 'rl',
github dingzhiyuan / pxtorem-cli / pxtorem-cli.js View on Github external
program
    .version('1.1.0')
    .option('-i, --input [path]', 'relative path to the stylesheet to process')
    .option('-o, --output [path]', 'the destination to save')
    .option('-r, --rootvalue [rootvalue]', 'Rem root value e.g. 16  Default: 16')
    .parse(process.argv);

/**
 * Error Handling io
 */
var _configs=readJson("pxtorem.json");

var options={}
options=_configs?extendObj(defaults,_configs):defaults;

if(!program.input && program.output){
    console.log(chalk.red('Error: --input was missing an attribute. Use --help for additional info'));
    process.exit(1);
}

if(!program.output && program.input){
    console.log(chalk.red('Error: --output was missing an attribute. Use --help for additional info'));
    process.exit(1);
}

if(program.rootvalue && isNaN(program.rootvalue)){
    console.log(chalk.red('Error: --rootvalue must be a Number. Use --help for additional info'));
    process.exit(1);
}

if(program.rootvalue){
    options.rootValue = program.rootvalue;
github mikunn / openapi2schema / index.js View on Github external
}

if (! program.input) {
	console.error('Option -i, --input  required. Display help with -h.');
	process.exit(1);
}


options = {
	'includeResponses': program.responses || false,
	'dateToDateTime': program.dateToDateTime || false,
	'supportPatternProperties': program.patternProperties || false,
	'clean': program.clean || false
};

openapi2schema(program.input, options, function(err, res) {
	if (err) {
		return console.error(err);
	}

	print(res);
});

function print(data) {
	var spaces = program.prettyPrint ? 2 : null;
	console.log(JSON.stringify(data, null, spaces));
}
github AnyChart / AnyChart-NodeJS / demos / sample1 / index.js View on Github external
var anychart = require('anychart')(w);
var anychart_export = require('../../lib/anychart-export.js')(anychart);

program
    .version('0.0.1')
    .option('-i, --input [value]', 'path to input data file with chart, stage or svg', 'chart.js')
    .option('-o, --output [value]', 'path to output image or svg file.', 'image')
    .option('-t, --type [value]', 'type of output data.', 'png');

program.parse(process.argv);

if (!program.input) {
  console.log('Input data not found.');
} else {
  fs.readFile(program.input, 'utf8', function(err, data) {
    if (err) {
      console.log(err.message);
    } else {
      var chart;
      try {
        eval(data);
      } catch (e) {
        console.log(e.message);
        chart = null;
      }

      if (chart) {
        anychart_export.exportTo(chart, program.type).then(function(image) {
          fs.writeFile(program.output + '.' + program.type, image, function(err) {
            if (err) {
              console.log(err.message);
github rbtech / css-purge / css-purge.js View on Github external
options.trim = true;
			options.shorten = true;
		}

		cssPurge.purgeCSS(program.cssinput, options, function(error, result){
			if (error)
				console.log(error)
			else
				console.log(result);
		});
	}

} else if (program.input && program.inputhtml && program.output) {

	options = {
		css: program.input,
		css_output: program.output,
		special_reduce_with_html: true,
		html: program.inputhtml,
		verbose : (program.verbose) ? true : false
	};

	if (program.customconfig === undefined) {
		options.trim = true;
		options.shorten = true;
	}

	cssPurge.purgeCSSFiles(
		options, 
		(program.customconfig !== undefined) ? program.customconfig : 'cmd_default'
	);
github AnyChart / AnyChart-NodeJS / demos / sample2 / index.js View on Github external
var document = jsdom('<div id="chart-container"></div>');
var window = document.defaultView;

var anychart = require('anychart')(window);
var anychart_export = require('../../lib/anychart-export.js')(anychart);

program
    .version('0.0.1')
    .option('-i, --input [value]', 'path to input data file with chart, stage or svg', 'chart.js')
    .option('-o, --output [value]', 'path to output directory for reports.', 'reports')
    .option('-n, --name [value]', 'name of report.', 'report.html');

program.parse(process.argv);


fs.readFile(program.input, 'utf8', function(err, data) {
  if (err) {
    console.log(err.message);
  } else {
    var chart;
    try {
      chart = eval(data);
    } catch (e) {
      console.log(e.message);
      chart = null;
    }

    var isExistOutputReportDir = fs.existsSync(program.output);
    if (!isExistOutputReportDir) {
      fs.mkdirSync(program.output);
    }
github wdullaer / raml2slate / lib / cli.js View on Github external
const pjson = require('../package.json')

const defaultInput = path.resolve(process.cwd(), 'api.raml')
const defaultOutput = path.resolve(process.cwd(), 'public')

program
  .version(pjson.version)
  .option('-i, --input ', 'RAML file to render', isValidPath.bind(null, fs.constants.R_OK))
  .option('-o, --output <dir>', 'Directory to output the documentation to', isValidPath.bind(null, fs.constants.W_OK))
  .option('-l, --logo ', 'Path to the logo to include in the documentation', isValidPath.bind(null, fs.constants.R_OK))
  .option('-t, --theme ', 'Path to a colour theme file', isValidPath.bind(null, fs.constants.R_OK))
  .option('--generate-theme', 'Generates the default colour theme')
  .parse(process.argv)

let options = {
  input: program.input || defaultInput,
  output: program.output || defaultOutput,
  logo: program.logo,
  theme: program.theme
}

if (program.generateTheme) {
  fs.createReadStream(getDefaultThemePath(), {encoding: 'utf8'})
    .pipe(process.stdout)
} else {
  render(options)
}

function isValidPath (access, input) {
  let result = path.resolve(input)
  fs.accessSync(result, access)
  return result</dir>
github elrumordelaluz / svgson / bin / svgson.js View on Github external
program
  .version(version)
  .usage('[options] ')
  .option('-i, --input [input]', 'Specifies input folder or file. Default current')
  .option('-o, --output [output]', 'Specifies output file. Default ./svgson.json')
  .option('-t, --title', 'Add title from svg filename')
  .option('-P, --prefix ', 'Remove prefix from title')
  .option('-S, --suffix ', 'Remove suffix from title')
  .option('-k, --key [key]', 'Specifies a key where include all paths')
  .option('-a, --attrs ', 'Custom Attributes: key=value, key=value...', list, [])
  .option('-p, --pretty', 'Prettyfied JSON')
  .option('-s, --svgo', 'Optimize SVG with SVGO')
  .parse(process.argv);


const SRC_DIR   = program.input || '.';
const DEST_FILE = program.output || 'svgson.json';

let sourceDir, sourceFile;

const readFolder = () =&gt; {
  if (!fs.statSync(SRC_DIR).isDirectory()) {
    sourceFile = path.basename(SRC_DIR);
    sourceDir = path.dirname(SRC_DIR);
    return Promise.resolve([SRC_DIR])
  }

  return fs.readdir(SRC_DIR);
};

const filterFile = (file) =&gt; {
  return path.extname(file) === '.svg';