How to use the yargs.option 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 Tokimon / vanillajs-browser-helpers / tasks / spec.js View on Github external
/* eslint-disable no-console */

const nPath = require('path');

const fs = require('fs-promise');
const glob = require('glob-promise');

const rollup = require('rollup');
const rollupBabel = require('rollup-plugin-babel');
const rollupNode = require('rollup-plugin-node-resolve');
const rollupCJS = require('rollup-plugin-commonjs');
const rollupIstanbul = require('rollup-plugin-istanbul');
const rollupIncludePaths = require('rollup-plugin-includepaths');

const args = require('yargs')
  .option('instrument', {
    type: 'boolean',
    alias: 'i',
    describe: 'Instrument the code using Istanbul'
  })
  .option('root', {
    alias: 'r',
    describe: 'Root path to search for the test directory',
    type: 'string',
    choices: ['.', 'es5'],
    default: '.'
  })
  .help()
  .alias('help', 'h')
  .argv;
github goopscoop / svg-to-react-cli / index.js View on Github external
const path = require('path');
const HTMLtoJSX = require('htmltojsx');
const jsdom = require('jsdom-no-contextify');

// Language files
const content = require('./lang/en');

// Local includes
const createComponentName = require('./src/createComponentName');
const formatSVG = require('./src/formatSVG');
const generateComponent = require('./src/generateComponent');
const printErrors = require('./src/output').printErrors;
const removeStyle = require('./src/removeStyle');

// Argument setup
const args = yargs
  .option('format', { default: true })
  .option('output', { alias: 'o' })
  .option('rm-style', { default: false })
  .option('force', { alias: 'f', default: false })
  .argv;

// Resolve arguments
const firstArg = args._[0];
const newFileName = args._[1] || 'MyComponent';
const outputPath = args.output;
const rmStyle = args.rmStyle;
const format = args.format;


// Bootstrap base variables
const converter = new HTMLtoJSX({ createClass: false });
github PACKED-vzw / CultURIze / src / cli.ts View on Github external
function parseCLIArgs(cliargs: any) {
  log.info(cliargs);
  log.info("parse");
  const args = require("yargs")
      .option("n", {
          alias: "nginx",
          type: "boolean",
          default: false})
      .option("a", {
          alias: "apache",
          type: "boolean",
          default: false})
      .option("csv", {
          type: "string",
          nargs: 1,
          demand: true})
      .parse(cliargs)
      .argv;

      // .option("t", {
github sillsdev / web-languageforge / gulpfile.js View on Github external
gulp.task('test-e2e-setupTestEnvironment', function (cb) {
  var params = require('yargs')
    .option('webserverHost', {
      demand: true,
      describe: 'hostname (without the protocol) for E2E testing',
      type: 'string' })
    .option('dest', {
      demand: false,
      describe: 'destination of test environment',
      type: 'string' })
    .fail(yargFailure)
    .argv;
  var options = {
    dryRun: false,
    silent: false,
    cwd: getTestCwd(params.dest)
  };
  execute(
github sifive / duh / bin / duh-import-verilog-ports-simple.js View on Github external
#!/usr/bin/env node
'use strict';

const yargs = require('yargs');
const path = require('path');
const JSON5 = require('json5');
const concat = require('concat-stream');
const fs = require('fs-extra');

const pinlister = require('pinlist/lib/pinlister-simple.js');

const argv = yargs
  .option('output', {
    alias: 'o',
    describe: 'result file'
  })
  .version()
  .help()
  .argv;

async function gotInput(source) {
  const folderName = path.basename(process.cwd());
  const fileName = argv._[0] || folderName + '.json5';
  const duhRaw = await fs.readFile(fileName, 'utf-8');
  const duh = JSON5.parse(duhRaw);
  const pins = pinlister(source);
  duh.definitions = duh.definitions || {};
  duh.definitions.ports = duh.definitions.ports || {};
github imodeljs / imodeljs / tools / build / scripts / ignoreargs.js View on Github external
function getArgs() {
  const args = yargs
    .option("verbose", {
      alias: "v"
    })
    .option("detail", {
      alias: "d",
      type: "number",
    })
    .help().argv;
  return args;
}
github AugurProject / augur / packages / augur-core / source / tools / migrateRep.ts View on Github external
#!/usr/bin/env node

require('source-map-support').install();
import * as fs from "async-file";
import { LegacyRepMigrator } from '../libraries/LegacyRepMigrator';
import * as yargs from 'yargs';

let argv =  yargs
    .option('repAddress', {
        describe: "Address of the new REP contract to migrates to",
    })
    .option('balances', {
        describe: "File containing newline delimited addresses that have REP balances",
    })
    .option('allowanceOwners', {
        describe: "File containing newline delimited addresses for the allowance owners",
    })
    .option('allowanceSpenders', {
        describe: "File containing newline delimited addresses that the allowance spenders",
    })
    .option('chunkSize', {
        describe: "Number of addresses to use per TX",
        default: 25,
    })
github eclipse-theia / theia / dev-packages / application-manager / src / generator / abstract-generator.ts View on Github external
*
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the Eclipse
 * Public License v. 2.0 are satisfied: GNU General Public License, version 2
 * with the GNU Classpath Exception which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 ********************************************************************************/

import * as os from 'os';
import * as fs from 'fs-extra';
import * as yargs from 'yargs';
import { ApplicationPackage } from '@theia/application-package';

const argv = yargs.option('mode', {
    description: 'Mode to use',
    choices: ['development', 'production'],
    default: 'production'
}).option('split-frontend', {
    description: 'Split frontend modules into separate chunks. By default enabled in the dev mode and disabled in the prod mode.',
    type: 'boolean',
    default: undefined
}).option('app-target', {
    description: 'The target application type. Overrides ["theia.target"] in the application\'s package.json.',
    choices: ['browser', 'electron'],
}).argv;
const mode: 'development' | 'production' = argv.mode;
const splitFrontend: boolean = argv['split-frontend'] === undefined ? mode === 'development' : argv['split-frontend'];

export abstract class AbstractGenerator {
github copenhagenjs / copenhagenjs.dk / web / utils / fetch-meetup.js View on Github external
const argv = require('yargs')
  .option('id', {
    describe: 'meetup id to be fetched'
  })
  .option('file', {
    describe: 'save output if defined'
  })
  .demandOption(['id'])
  .help().argv
const fetch = require('node-fetch')
const { writeFileSync } = require('fs')

async function fetchEventData(id) {
  const req = await fetch(`https://api.meetup.com/copenhagenjs/events/${id}`)
  const {
    description,
    link,
github DataFire / DataFire / src / cmd.js View on Github external
}, {
    name: 'inputFile',
    alias: 'f',
    description: "JSON or YAML file containing input",
  }, {
    name: 'outputFile',
    alias: 'o',
    description: "Where to output the result (otherwise STDOUT)",
  }]
}, {
  name: 'test ',
  description: "Run a test stored in DataFire.yml",
  runner: require('./commands/test'),
}]

let args = require('yargs')
           .option('v', {alias: 'verbose'})
           .global('v')
           .recommendCommands();

COMMANDS.forEach(cmd => {
  cmd.examples = cmd.examples || [];
  cmd.options = cmd.options || [];
  args = args.command(
        cmd.name,
        cmd.description,
        (yargs) => {
          cmd.options.forEach(o => {
            yargs.option(o.name, {
              alias: o.alias,
              describe: o.description,
              demand: o.required,