How to use the cli.setUsage 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 GameMakerDiscord / Rubber / src / cli.ts View on Github external
#!/usr/bin/env node
// Wrapper for rubber as a CLI
// Has almost the same functionality as
// using it from JS, besides the ability
// to process output.
import * as cli from "cli";
import { default as chalk } from "chalk";
import { readFileSync, existsSync, statSync, readdirSync, PathLike } from "fs";
import { join, resolve } from "path";
import * as rubber from './rubber';
import { getUserDir } from "./utils/preferences_grab";
cli.setUsage("rubber [options] path/to/project.yyp [output file]");

/**
 * Preform basic checks to see if a .yyp is actually valid.
 */
function validateYYP(path: PathLike) {
    let projectRead;
    try {
        projectRead = JSON.parse(readFileSync(path).toString());
    } catch (e) {
        projectRead = {};
    }
    return ("IsDnDProject" in projectRead) &&
        ("id" in projectRead) &&
        ("mvc" in projectRead) &&
        ("resources" in projectRead) &&
        (projectRead.modelName === "GMProject");
github geometria-lab / Beseda / bin / benchmarks.js View on Github external
#!/usr/bin/env node

var cli  = require('cli');
var util = require('util');
var fs = require('fs');
var Benchmark = require('../benchmarks/lib/benchmark.js');

cli.parse({
    config  : [ 'c',   'Benchmarks config file', 'string' ],
    results : [ 'r',   'Save results to HTML file', 'string' ]
});

cli.setUsage('benchmarks [OPTIONS]');

cli.main(function(args, option) {
	if (!option.config) {
		cli.getUsage();
		process.exit(1);
	}

	var config = JSON.parse(fs.readFileSync(option.config, 'utf8'));

	var benchmark = new Benchmark(config);
	benchmark.on('finish', function() {
		if (option.results) {
			var results = this.getResults();
			var options = this.getOptions();

			var imgs = []
github weseek / growi / bin / revision-string-replacer.js View on Github external
var cli = require('cli')
 , mongo   = require('mongoose')
 , async   = require('async')
 ;

cli.setUsage('MONGO_URI=mongodb://user:password@host/dbnae node bin/revision-string-replacer.js --from=\'aaa\' --to=\'bbb\'\n\n  This means that replace string "aaa" to "bbb" from all revisions.');
cli.parse({
    from: [false, 'Specified string is a target to replace.', 'string'],
    to: [false, 'Replace string which specified by "from" to this string.', 'string'],
    dry: [false, 'Dry run', 'boolean'],
});


cli.main(function(args, options)
{
  var app = {set: function(v) { }}
    , c = this
    , from = options.from
    , to = options.to
    , dry = options.dry
    ;
github dylang / changelog / lib / cli.js View on Github external
"use strict";

var CLI = require('cli');
var FS = require('fs');
var hasColor = require('has-color');
var changelog = require('./changelog');
var log = require('./log');

CLI.setUsage('changelog  [release] [options]\n' +
    '  changelog  [release] [options]\n' +
    '\n' +
    'Module name:\n' +
    '   $ changelog npm\n' +
    '\n' +
    'Github repo:\n' +
    '   $ changelog github.com/isaacs/npm\n' +
    '   $ 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({
github MM56 / mm-packer / bin / mm-packer.js View on Github external
#!/usr/bin/env node

const cli = require('cli');
const pkg = require('../package.json');
const packer = require("../index.js");

cli.setApp(pkg.name, pkg.version);
cli.enable("version", "status");
cli.setUsage("mm-packer -s files/original -o files/packed");

cli.parse({
	source:	["s", "Source directory", "file"],
	output:	["o", "Output directory", "file"],
	name:	["n", "Pack files name", "string", "pack"],
});

cli.main((args, options) => {
	if(options.source && options.output && options.name) {
		options.debug = process.argv.indexOf("--debug") > -1;
		packer(options);
	} else {
		cli.getUsage();
	}
});
github smfoote / tornado / bin / tornado.es6 View on Github external
#!/usr/bin/env node

import cli from 'cli';
import fs from 'fs';
import {version} from '../package.json';

import parser from '../dist/parser';
import compiler from '../dist/compiler';

cli.enable('glob', 'version');

cli.setApp('tornado', version);

cli.setUsage(`${cli.app} [options] [path1 [path2 path3]]

  Compile all .td files in a directory:
${cli.app} --output=compiled.js templates/**/*.td`);

cli.parse({
  name: ['n', 'The name by which the template will be registered (defaults to path)', 'string'],
  output: ['o', 'Concatenate all output to this file', 'path'],
  split: ['s', 'Should the output files be split into their own files (true) or concatenated (false)', 'boolean'],
  pwd: [false, 'generate template names starting from this directory', 'string'],
  mode: ['m', 'Compling for `production` or `dev`', 'string']
});

let streams;
let path = cli.native.path;

function glob(globPaths) {