How to use the yargs.command function in yargs

To help you get started, we’ve selected a few yargs 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 gilbarbara / is-lite / tools / index.ts View on Github external
/* tslint:disable:no-console */
import { promisify } from 'util';
import { exec } from 'child_process';
import chalk from 'chalk';
import * as yargs from 'yargs';

const run = promisify(exec);

module.exports = yargs
  .command({
    command: 'has-commits',
    describe: 'has new remote commits',
    handler: () => {
      run('git rev-parse --is-inside-work-tree')
        .then(() =>
          run('git remote -v update')
            .then(() =>
              Promise.all([
                run('git rev-parse @'),
                run('git rev-parse @{u}'),
                run('git merge-base @ @{u}'),
              ])
                .then(values => {
                  const [
                    { stdout: $local },
github OpenNTF / WebDevToolkitForDx / digexp-wcm-design / wcmdesigns.js View on Github external
}*/
  };
  // will only show the errors
  result.trace = result.info = result.debug = result.warn = result.log = result.error = function() {};
  return result;
};

var fs = require("fs");
var path = require("path");

var yargs = require("yargs");
var prompt = require("prompt");

var pkg = require("./package.json");

var argv = yargs
  .command("init", "initialize the settings for the WCM library", function(yargs) {
    argv = yargs
      .option('d', {
        description: 'The directory that will contain the WCM library',
        alias: 'dir',
        default: './',
        type: 'string'
      })
      .option('v', {
        description: 'To get verbose output',
        alias: 'verbose',
        type: 'boolean'
      })
      .help('help')
      .alias('h', 'help')
      .argv;
github elementary / houston / src / cli / houston.ts View on Github external
// Command line files are allowed to have console log statements
// tslint:disable no-console

import * as yargs from 'yargs'

import { getProgramConfig } from '../lib/config/loader'

import * as api from './api'
import * as client from './client'
import * as migrate from './migrate'
import * as repo from './repo'
import * as seed from './seed'
import * as work from './work'

yargs.command(api, api.describe, api.builder)
yargs.command(client, client.describe, client.builder)
yargs.command(migrate, migrate.describe, migrate.builder)
yargs.command(repo, repo.describe, repo.builder)
yargs.command(seed, seed.describe)
yargs.command(work, work.describe, work.builder)

yargs.help('h').alias('h', 'help')
yargs.option('version', { alias: 'v', describe: 'Outputs the current houston version', type: 'boolean' })
yargs.option('config', { alias: 'c', describe: 'Path to configuration file', type: 'string' })

yargs.recommendCommands()
yargs.showHelpOnFail(true)

const argv = yargs.argv

if (argv.version === true) {
github mxmul / webpack-why / src / index.js View on Github external
function main(): void {
    const command = Yargs.command(
        '$0  ',
        'Determine why a module is included in a Webpack bundle.',
        yargs => {
            yargs
                .positional('file', {
                    describe:
                        'path to a stats file generated by `webpack --json`',
                })
                .positional('module', {
                    describe: 'the name of the module',
                });
        },
    ).help();

    const { argv } = command;
github aurelia / tools / src / cli.js View on Github external
const path = require('path');
const rimraf = require('rimraf').sync;
const spawn = require('child_process').spawn;
const proxySpawned = require('./cli-util').proxySpawned;
const projectDir = process.cwd();
const docShape = require('./doc-shape');
const docShapeDefs = require('./doc-shape-defs');

let tscPath;
try {
  tscPath = require.resolve(path.join(projectDir, 'node_modules', 'typescript/bin/tsc'));
} catch (_) {
  tscPath = require.resolve('typescript/bin/tsc');
}

const argv = require('yargs')
  .command('ts-build-all', 'Build multiple versions of the project', {
      project: {
        alias: 'p',
        describe: 'TypeScript project file or folder',
        type: 'string',
        default: 'tsconfig.build.json'
      },
      outDir: {
        alias: 'out',
        describe: 'Output directory for compilations',
        type: 'string',
        default: 'dist'
      },
      'continue-when-failed': {
        describe: 'Do not bail when one compilation fails',
        type: 'boolean',
github y12studio / dltdojo / index.js View on Github external
function main() {
    require('yargs')
        .command({
            command: 'start',
            desc: 'start file/rpc server',
            handler: startServer
        })
        .command({
            command: 'rpc',
            desc: 'rpc client',
            handler: (yargs) => {
                testRpc()
            }
        })
        .command({
            command: 'btc  ',
            desc: 'bitcond getinfo',
            builder: (yargs) => {
github patrickmichalina / fusing-angular-cli / src / commands / create.ts View on Github external
import { load, commands } from 'npm'
import generateTsConfig from '../generators/tsconfig.gen'
import generateTsDeclartionFile from '../generators/declarations.gen'
import generateDotEnv from '../generators/env.gen'
import generateIdeStubs from '../generators/ide.gen'
import {
  QuestionWrapper,
  QustionResponse,
  WorkingAnswersDictionary,
  AnswersDictionary,
  FirebaseConfig
} from './create-common'
import { Q_INCLUDE_FIREBASE, Q_FIREBASE } from './create-firebase'
import { favicon_ } from './favicon'

command(
  'create [overwrite]',
  'create a new application',
  args => args,
  args => {
    const force = args.o || false
    create(force)
  }
).option('overwrite', {
  alias: 'o',
  description: 'Overwrite existing application folder'
})

const Q_FULL_NAME: QuestionWrapper = {
  question: {
    name: 'fullname',
    message: 'App Full Name:',
github BrowserSync / browser-sync / bin / browser-sync2.js View on Github external
var startOpts  = require("../lib/cli/opts.start.json");
var reloadOpts = require("../lib/cli/opts.reload.json");
var recipeOpts = require("../lib/cli/opts.recipe.json");
var pkg = require("../package.json");
var utils = require("../lib/utils");

/**
 * Handle cli input
 */
if (!module.parent) {
    var yargs = require("yargs")
        .command('start', 'Start the server')
        .command('init', 'Create a configuration file')
        .command('reload', 'Send a reload event over HTTP protocol')
        .command('recipe', 'Generate the files for a recipe')
        .version(function () {
            return pkg.version;
        })
        .epilogue("For help running a certain command, type  --help\neg: $0 start --help");

    var argv    = yargs.argv;
    var command = argv._[0];

    var valid = ['start', 'init', 'reload', 'recipe'];
    if (valid.indexOf(command) > -1) {
        handleIncoming(command, yargs.reset());
    } else {