How to use the cli.parse function in cli

To help you get started, we’ve selected a few cli 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 oklai / koala / src / app / node_modules / jshint / node_modules / cli / examples / command.js View on Github external
#!/usr/bin/env node

var cli = require('cli');

//The second (optional) argument of cli.parse() is a command list 
//Type `./command.js --help` for usage info

//cli enables auto-completion of commands (similiar to npm), e.g. all of
//the following are equivalent and result in "Command is: install":
//    $ ./command.js install
//    $ ./command.js inst
//    $ ./command.js i

cli.parse(null, ['install', 'test', 'edit', 'remove', 'uninstall', 'ls']);

console.log('Command is: ' + cli.command);
github AdobeXD / xdpm / index.js View on Github external
"j",
    "If true, indicates that JSON output should be generated",
    "bool",
    false
  ],
  //  mode: ["m", "Indicates which plugin mode to use", ["d", "p"], "d"],
  overwrite: ["o", "Allow overwriting plugins", "bool", false],
  which: [
    "w",
    "Which Adobe XD instance to target",
    ["r", "p", "d", "release", "pre", "prerelease", "dev", "development"],
    "r"
  ]
};

const parsedOpts = cli.parse(options, commands);

if (parsedOpts.json) {
  cli.status = function() {};
} else {
  cli.info(`xdpm ${package.version} - XD Plugin Manager CLI`);
  cli.info(`Use of this tool means you agree to the Adobe Terms of Use at
https://www.adobe.com/legal/terms.html and the Developer Additional
Terms at https://wwwimages2.adobe.com/content/dam/acom/en/legal/servicetou/Adobe-Developer-Additional-Terms_en_US_20180605_2200.pdf.`);
}

const { command, args } = cli;

if (parsedOpts.which) {
  parsedOpts.which = parsedOpts.which[0];
}
github senchalabs / AppInspector / node_modules / grunt-contrib-jshint / node_modules / jshint / src / cli.js View on Github external
interpret: function (args) {
    cli.setArgv(args);
    cli.options = {};

    cli.enable("version", "glob", "help");
    cli.setApp(path.resolve(__dirname + "/../package.json"));

    var options = cli.parse(OPTIONS);
    // Use config file if specified
    var config;
    if (options.config) {
      config = exports.loadConfig(options.config);
    }

    switch (true) {
    // JSLint reporter
    case options.reporter === "jslint":
    case options["jslint-reporter"]:
      options.reporter = "./reporters/jslint_xml.js";
      break;

    // CheckStyle (XML) reporter
    case options.reporter === "checkstyle":
    case options["checkstyle-reporter"]:
github victorporof / Sublime-JSHint / scripts / node_modules / jshint / src / cli.js View on Github external
interpret: function(args) {
    cli.setArgv(args);
    cli.options = {};

    cli.enable("version", "glob", "help");
    cli.setApp(path.resolve(__dirname + "/../package.json"));

    var options = cli.parse(OPTIONS);
    // Use config file if specified
    var config;
    if (options.config) {
      config = exports.loadConfig(options.config);
    }

    switch (true) {
    // JSLint reporter
    case options.reporter === "jslint":
    case options["jslint-reporter"]:
      options.reporter = "./reporters/jslint_xml.js";
      break;

    // CheckStyle (XML) reporter
    case options.reporter === "checkstyle":
    case options["checkstyle-reporter"]:
github MrMaxie / get-google-fonts / cli.js View on Github external
#!/usr/bin/env node

const cli = require('cli')
const GGF = require('./main.js')

let ggf = new GGF

// Default Config
let dc = ggf.getConfig()

cli.enable('help')

let res = cli.parse({
	input:            ['i', 'Input URL of CSS with fonts', 'url'],
	output:           ['o', 'Output directory', 'string', dc.outputDir],
	path:             ['p', 'Path placed before every source of font in CSS', 'string', dc.path],
	css:              ['c', 'Name of CSS file', 'string', dc.cssFile],
	template:         ['t', 'Template of font filename', 'string',  dc.template],
	useragent:        ['u', 'User-agent used at every connection', 'string', false],
	quiet:            ['q', 'Don\'t displays a lot of useful information'],
	base64:           ['b', 'Save fonts inside CSS file as base64 URIs'],
	'non-strict-ssl': [false, [
		'Force to accepts only valid SSL certificates; in some cases,',
		'such proxy or self-signed certificates should be turned off',
	].join('')],
	overwriting:      ['w', 'Allows overwrite existing files'],
	'print-options':  [false, 'Shows result options object without performing any action'],
	simulate:         ['s', 'Simulation; No file will be saved']
})
github nfriedly / Coin-Allocator / node_modules / grunt-contrib-jshint / node_modules / jshint / src / cli.js View on Github external
interpret: function (args) {
    cli.setArgv(args);
    cli.options = {};

    cli.enable("version", "glob", "help");
    cli.setApp(path.resolve(__dirname + "/../package.json"));

    var options = cli.parse(OPTIONS);
    // Use config file if specified
    var config;
    if (options.config) {
      config = exports.loadConfig(options.config);
    }

    switch (true) {
    // JSLint reporter
    case options.reporter === "jslint":
    case options["jslint-reporter"]:
      options.reporter = "./reporters/jslint_xml.js";
      break;

    // CheckStyle (XML) reporter
    case options.reporter === "checkstyle":
    case options["checkstyle-reporter"]:
github tensult / aws-automation / update_timeout_for_lambda_functions.js View on Github external
/**
 * Setting proper timeout for lambda functions is important as it will 
 * impact the performance. 
 *
 * We can use this script to set timeout for all our Lambda functions at once.
 */
const awsConfigHelper = require('./util/awsConfigHelper');
const wait = require('./util/wait');
const AWS = require('aws-sdk');
const cli = require('cli');

const cliArgs = cli.parse({
    region: ['r', 'AWS region', 'string'],
    filterName: ['f', 'Pass filter name to filter Lambda functions', 'string'],
    timeout: ['t', 'Function timeout in seconds', 'number']
});

if (!cliArgs.region || !cliArgs.timeout) {
    cli.getUsage();
}

const filterRegex = new RegExp(cliArgs.filterName);

let isCompleted = false;
let nextToken = undefined;

async function setFunctionTimeout() {
    await awsConfigHelper.updateConfig(cliArgs.region);
github node-js-libs / cli / examples / sort.js View on Github external
#!/usr/bin/env node

var cli = require('cli');

var options = cli.parse({
    numeric: ['n', 'Compare using a numeric sort'],
    reverse: ['r', 'Reverse the results']
});

cli.withStdinLines(function (lines, newline) {
    lines.sort(!options.numeric ? null : function (a, b) {
        return parseInt(a) > parseInt(b);
    });
    if (options.reverse) {
        lines.reverse();
    }
    this.output(lines.join(newline));
});
github deployjs / deployjs-cli / bin / deploy.js View on Github external
#!/usr/bin/env node

const UI = require('console-ui');
const cli = require('cli');

const Project = require('../models/project');
const CommandFactory = require('../commands/command-factory');

const discovery = require('../tasks/discover');

const pkg = require('../package.json');

let options = cli.parse({
  environment: [ 'e', 'A configured deployment environment, i.e. "staging", "production".', 'string', 'production'],
  verbose: ['v', 'Toggle verbosity', 'bool', false],
  revision: ['r', '("activate" only) revision to activate', 'string', false],
  activate: ['a', '("deploy" only) directly activate the deployed revision', 'bool', false]
}, ['deploy', 'list', 'activate']);

let ui = new UI({
  inputStream: process.stdin,
  outputStream: process.stdout,
  writeLevel: 'INFO'
});

ui.write('DeployJS CLI v' + pkg.version);

let commandFactory = new CommandFactory();
github tensult / aws-automation / delete_old_lambda_function_versions.js View on Github external
/**
 * Deletes lambda function versions. 
 *
 * We can use this script to delete old versions of all our Lambda functions at once.
 */
const awsConfigHelper = require('./util/awsConfigHelper');
const wait = require('./util/wait');
const AWS = require('aws-sdk');
const cli = require('cli');

const cliArgs = cli.parse({
    region: ['r', 'AWS region', 'string'],
    filterName: ['f', 'Pass filter name to filter Lambda functions', 'string'],
    maxVersions: ['v', 'Maximum versions to keep: should be greater than 0', 'number', 3]
});

if (!cliArgs.region || cliArgs.maxVersions < 1) {
    cli.getUsage();
}

let lambda;
const filterRegex = new RegExp(cliArgs.filterName);

async function getFunctionVersions(functionName) {
    let functionVersions = [];
    let isCompleted = false;
    let marker = undefined;