How to use the cli.main 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 ricardocasares / gitlogme / index.js View on Github external
* Parses the arguments given options
 */
cli.parse({
    name: ["n", "Your git user", "string"],
    email: ["e", "Your git email", "email"],
    since: ["s", "Date to log from, YYYY-MM-DD", "string", user.dates.since],
    until: ["u", "Date to log to, YYYY-MM-DD", "string", user.dates.until],
    format: ["f", "Git log format", "string", "%h%x09%an%x09%ad%x09%s"],
    open: ["o", "Open file upon creation", "boolean", false],
    dest: ["d", "Where do you want to save the file", "path", user.home]
});

/**
 * Call to main method
 */
cli.main(main);

/**
 * Main method
 *
 * @param  {Array}  args     Arguments array
 * @param  {Object} options  Options object
 */
function main() {
    prepareOptions();
    cli.spinner(spinner);
    var git = spawn("git", command(), { cwd: process.cwd() });
    var log = stream(cli.options.filename);
    // pipe stdout to log stream
    git.stdout.pipe(log);
    // say good-bye!
    git.on("close", onGitClose);
github urish / firebase-server / bin / firebase-server.js View on Github external
cli.parse({
	rest: ['e', 'Enable REST HTTP API'],
	verbose: ['v', 'Enable verbose (debug) output'],
	port: ['p', 'Listen on this port', 'number', 5000],
	address: ['a', 'Bind to this address', 'string'],
	daemon: ['b', 'Daemonize (run in background)'],
	pid: [false, 'Write PID to this path', 'string'],
	name: ['n', 'Hostname of the firebase server', 'string', 'localhost.firebaseio.test'],
	data: ['d', 'JSON data to bootstrap the server with', 'string', '{}'],
	file: ['f', 'JSON file to bootstrap the server with', 'file'],
	rules: ['r', 'JSON file with security rules to load', 'file'],
	secret: ['s', 'Shared client auth token secret', 'string'],
	version: [false, 'Output the version number'],
});

cli.main(function (args, options) { // eslint-disable-line max-statements,complexity
	let pidPath = options.pid;
	if (pidPath) {
		pidPath = path.resolve(pidPath);
	}

	if (options.daemon) {
		// Work around https://github.com/indexzero/daemon.node/issues/41
		require('daemon')({cwd: '/'});
	}

	if (options.pid) {
		fs.writeFile(options.pid, process.pid.toString(), () => {});

		process.on('exit', code => {
			fs.unlinkSync(options.pid, () => {}); // eslint-disable-line no-sync
		});
github slively / loopback-discover-models / cli.js View on Github external
modelConfigPath: [false, 'Path to model-config.json (relative to CWD)', 'path', '/server/model-config.json'],
        modelDir: [false, 'Path to models folder (relative to CWD)', 'path', '/server/models'],
        dataSource: [false, 'Name of the data source from data sources.json (required)', 'string', 'db'],
        allNewModels: [false, 'Discover and create all models not in modelDir', 'boolean', 'false' ],
        modelName:  [false, 'Name of a single model/table/collection to create (if not all models)', 'string' ],
        owner: [false, 'Name of owner/schema/database for the models', 'string'],
        relations: [false, 'Include relations', 'boolean',  'false'],
        allOwners: [false, 'Include All Owners', 'boolean',  'false'],
        views: [false, 'Include views', 'boolean',  'false'],
        skip: [false, 'Comma separate model names to skip when discovering new models', 'string', '']
    };

cli.width = 120;
cli.parse(flags);

cli.main(function checkPrompt(args, options) {
    if (options.prompt) {
        // map cli flags into cli-prompt options
        prompt.multi(Object.keys(flags)
            .filter(function(key){
                return key !== 'prompt';
            })
            .map(function(key) {
                var flag = flags[key];
                return {
                    key: key,
                    label: flag[1],
                    type: flag[2],
                    default: flag[3]
                }
            }), main);
        return;
github slaporte / qualityvis / js / gadget_node.js View on Github external
+ ''  + zero_fill(start_time.getDate(), 2);
    var filename = prefix + extension;
    if (path_lib.existsSync(filename)) {
	var suffix;
	for (var i=2; i<100; ++i) {
	    suffix = zero_fill(i,2);
	    if (!path_lib.existsSync(prefix+suffix+extension)) {
		filename = prefix + '_' + suffix + extension;
		break;
	    }
	}
    }
    return filename;
}

cli.main(function(args, options) {
    // update global constants
    EV_CONCURRENCY    = options.evaluator_workers;
    QUERY_CONCURRENCY = options.query_workers;
    CAT_CONCURRENCY   = options.cat_workers;
    GLOBAL_TIMEOUT    = options.global_timeout;
    
    mq     = queue(QUERY_CONCURRENCY, 'Query queue');
    jsdomq = queue(EV_CONCURRENCY, 'Evaluator queue');
    catq   = queue(CAT_CONCURRENCY, 'Category queue');

    var recursive     = options.recursive || false;
    var article_count = options.article_count;
    var category_name = options.category_name;
    var log_file      = options.log_file;
    var debug_mode    = options.debug;
    var start_time    = new Date();
github dylang / changelog / lib / cli.js View on Github external
'   $ changelog isaacs/npm\n' +
    '\n' +
    'Versions:\n' +
    '   latest   Default: Show only the latest versions. ex: $ changelog npm latest\n' +
    '   all      Show all versions.                      ex: $ changelog npm all\n' +
    '   number   Show that many recent versions.         ex: $ changelog npm 3\n' +
    '   n.n.n    Show changes for a specific version.    ex: $ changelog npm 1.3.11'

).parse({
    color:      ['c', 'Output as Color (terminal default)'],
    markdown:   ['m', 'Output as Github-flavored Markdown (file default)'],
    json:       ['j', 'Output as JSON'],
    debug:      ['d', 'Enable debugging']
});

CLI.main(function (args, options) {
    log.enableDebug(options.debug);

    var project = args[0];

    var releaseRequested = args[1] || 'latest';

    if (project === 'all') {
        releaseRequested = 'all';
        project = null;
    }

    if (project === 'latest') {
        releaseRequested = 'latest';
        project = null;
    }