How to use the yargs.options 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 mjmlio / mjml / packages / mjml-cli / src / client.js View on Github external
let KEEP_OPEN = false

  const error = msg => {
    console.error('\nCommand line error:') // eslint-disable-line no-console
    console.error(msg) // eslint-disable-line no-console

    process.exit(1)
  }

  const pickArgs = args =>
    flow(
      pick(args),
      pickBy(e => negate(isNil)(e) && !(isArray(e) && isEmpty(e))),
    )

  const argv = yargs
    .options({
      r: {
        alias: 'read',
        describe: 'Compile MJML File(s)',
        type: 'array',
      },
      m: {
        alias: 'migrate',
        describe: 'Migrate MJML3 File(s)',
        type: 'array',
      },
      v: {
        alias: 'validate',
        describe: 'Run validator on File(s)',
        type: 'array',
      },
github flaviuse / mern-authentication / client / node_modules / webpack-dev-server / bin / webpack-dev-server.js View on Github external
console.error('-> When using yarn: yarn add -D webpack-cli');

  process.exitCode = 1;
}

yargs.usage(
  `${getVersions()}\nUsage:  https://webpack.js.org/configuration/dev-server/`
);

// eslint-disable-next-line import/no-extraneous-dependencies
require('webpack-cli/bin/config-yargs')(yargs);

// It is important that this is done after the webpack yargs config,
// so it overrides webpack's version info.
yargs.version(getVersions());
yargs.options(options);

const argv = yargs.argv;

// eslint-disable-next-line import/no-extraneous-dependencies
const config = require('webpack-cli/bin/convert-argv')(yargs, argv, {
  outputFilename: '/bundle.js',
});

// Taken out of yargs because we must know if
// it wasn't given by the user, in which case
// we should use portfinder.
const DEFAULT_PORT = 8080;

function processOptions(config) {
  // processOptions {Promise}
  if (typeof config.then === 'function') {
github Beven91 / react-native-on-web / packages / react-native-on-web / packager / index.js View on Github external
/**
 * 名称:react-native-on-web 打包发布入口
 * 日期:2017-05-18
 * 作者:Beven
 * 描述:用于进行web平台打包发布
 */

// 依赖>>:
let path = require('path');
let yargs = require('yargs');
let Pack = require('react-native-on-web-bundler');

let configPath = path.join(__dirname, 'rnw-config.js');

// 配置参数类型
yargs.options({
  'releaseDir': {
    type: 'string',
    alias: 't',
    describe: 'release assets target dir',
  },
  'client': {
    type: 'string',
    alias: 'c',
    describe: 'release client side code',
  },
  'server': {
    type: 'string',
    alias: 's',
    describe: 'release server side code',
  },
  'install': {
github timkelty / shipit-captain / lib / captain.js View on Github external
Captain.prototype.normalizeOptions = function(options) {
  var argv = yargs.options({
    'e': {
      alias: 'env'
    },
    'r': {
      alias: 'run'
    }
  }).argv;

  var run = argv.run ?
    argvRun.split(',').map(Function.prototype.call, String.prototype.trim) :
    false;

  options = _.defaults(options || {}, {
    targetEnv: argv.env || false,
    availableEnvs: _.without(Object.keys(this.shipitConfig), 'default'),
    run: run || [],
github alberto-acevedo / cesium-navigation / Examples / server.js View on Github external
(function() {
    "use strict";
    /*global console,require,__dirname,process*/
    /*jshint es3:false*/

    var express = require('express');
    var compression = require('compression');
    var path = require('path');

    var yargs = require('yargs').options({
        'port' : {
            'default' : process.env.PORT || 8080,
            'description' : 'Port to listen on.'
        },
        'public' : {
            'type' : 'boolean',
            'description' : 'Run a public server that listens on all interfaces.'
        },
        'help' : {
            'alias' : 'h',
            'type' : 'boolean',
            'description' : 'Show this help.'
        }
    });
    var argv = yargs.argv;
github openmobilityfoundation / mds-core / packages / mds-compliance / mds-compliance-cli.ts View on Github external
http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
 */
import * as fs from 'fs'
import log from '@mds-core/mds-logger'
import * as yargs from 'yargs'
import { Policy, Geography, ComplianceResponse, VehicleEvent, Device } from '@mds-core/mds-types'
import { filterPolicies, processPolicy, filterEvents } from './mds-compliance-engine'
import { validateEvents, validateGeographies, validatePolicies } from './validators'

const args = yargs
  .options('geographies', {
    alias: 'g',
    demand: true,
    description: 'Path to geographies JSON',
    type: 'string'
  })
  .option('devices', {
    alias: 'd',
    demand: true,
    description: 'Path to devices JSON',
    type: 'string'
  })
  .options('events', {
    alias: 'e',
    demand: true,
    description: 'Path to events JSON',
github calvinmetcalf / derequire / bin / cmd.js View on Github external
#!/usr/bin/env node

var derequire = require('../');
var concat = require('concat-stream');
var fs = require('fs');

var argv = require('yargs')
  .options('t', {
      alias : 'to',
      default : '_dereq_',
      describe: 'token to change the variable into'
  })
   .options('f', {
      alias : 'from',
      default : 'require',
      describe: 'token to find and change'
  })
   .help('h')
   .alias('h', 'help')
   .version()
   .alias('v', 'version')
   .argv;
github pjcozzi / cesium-starter-app / server.js View on Github external
(function() {
    "use strict";
    /*global console,require,__dirname,process*/
    /*jshint es3:false*/

    var express = require('express');
    var compression = require('compression');
    var url = require('url');
    var request = require('request');

    var yargs = require('yargs').options({
        'port' : {
            'default' : process.env.PORT || 8080,
            'description' : 'Port to listen on.'
        },
        'public' : {
            'type' : 'boolean',
            'description' : 'Run a public server that listens on all interfaces.'
        },
        'upstream-proxy' : {
            'description' : 'A standard proxy server that will be used to retrieve data.  Specify a URL including port, e.g. "http://proxy:8000".'
        },
        'bypass-upstream-proxy-hosts' : {
            'description' : 'A comma separated list of hosts that will bypass the specified upstream_proxy, e.g. "lanhost1,lanhost2"'
        },
        'help' : {
            'alias' : 'h',
github anihalaney / rwa-trivia / cli.js View on Github external
.command(cmd, commandList[cmd].description, function (args) {
                argv = yargs.options(commandList[cmd].options);
                if (commandList[cmd].builder) {
                    commandList[cmd].builder(args);
                }

            }, async function (argv) {
                let executableCmd = commandList[cmd].command;