How to use yargs - 10 common examples

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 nativescript-vue / nativescript-vue-ui-tests / generate-screenshots.js View on Github external
(async function () {
    makeDir('screenshots');
    makeDir(`screenshots/${argv.runType}`);

    const appiumCaps = require('./appium.capabilities.json')[argv.runType];
    let args = new NsCapabilities({
      port: 4723,
      isSauceLab: argv.sauceLab || false,
      runType: argv.runType,
      appPath: argv.appPath, //'nativescriptvueuitests-debug.apk',
      appiumCaps: appiumCaps,
      verbose: argv.verbose || false,
      validateArgs: () => {},
    })
    // Hack to fix a `Cannot read property 'token' of undefined` error
    // See https://github.com/NativeScript/nativescript-dev-appium/issues/142
    if (args.isAndroid) {
        args.device = DeviceManager.getDefaultDevice(args, appiumCaps.avd);
    } else {
        args.device = DeviceManager.getDefaultDevice(args);
    }

    AppiumDriver.createAppiumDriver(args)
        .then(driver => run(driver))
        .then(() => console.log('Buh-Bye...'))
        .catch((err) => console.log(err));
})();
github liferay / alloy-editor / test / plugins / karma.js View on Github external
'use strict';

const alloyEditorDir = 'dist/alloy-editor/';

const argv = require('yargs').argv;
const path = require('path');

const coreSrcFiles = require('../core/_src.js');
const pluginsSrcFiles = require('./_src.js');

const preprocessors = {
    '**/*.html': ['html2js'],
    '+(test|src)/**/*.js': ['webpack']
};

if (!(argv.debug || argv.d)) {
    preprocessors[path.join(alloyEditorDir, 'test/**/*.js')] = ['coverage'];
}

const filesToLoad = [
    'test/vendor/zepto.js',
    'test/vendor/happen.js',

    /* CKEditor JS files */
    {
        pattern: path.join(alloyEditorDir, 'ckeditor.js'),
        included: true,
        watched: false
    }, {
        pattern: path.join(alloyEditorDir, 'styles.js'),
        included: true,
        watched: false
github Azure / azure-sdk-for-js / sdk / eventhub / testhub / cli.ts View on Github external
#!/usr/bin/env node

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
/* tslint:disable */

import * as yargs from "yargs";
const CtrlC = require("death");
import { cache } from "./commands/sendReceive";
import { partitionCount, uberStartTime, startTime } from "./commands/receive";
import { getCurrentCommand } from "./utils/util";

yargs
  .version("0.1.0")
  .commandDir("./commands")
  .strict()
  .option("h", { alias: "help" })
  .option("c", {
    alias: "conn-str",
    describe: "EventHub connection string.",
    string: true
  })
  .option("n", {
    alias: "hub",
    describe: "Name of the EventHub.",
    demandOption: true,
    string: true
  })
  .option("a", {
github ClintH / gtbg / app.js View on Github external
config.init(); // Load from config
config.layerArgs(argv); // Add in commandline overrides
presets.init();

if (!sox.exists()) {
  sox.install();
} else {
	// Sox is installed
	if (argv._.length === 0) { // No command
		var ui = require("./ui");
		ui(function(complete) {
			start(complete);
		});
	} else {
			var opt = argv._[0];
			if (opt == "info") {
				start({});
				return;
			}

			// Some command
			// Load preset
			var preset = presets.get(opt);
			if (preset === null) {
				console.log(chalk.red("Preset '" + opt + "' not found."));
				console.log("Try: " + presets.getKeys().join(", "));
			} else {
				// Got a valid preset
				start(preset);
			}
	}
github AlCalzone / node-tradfri-client / maintenance / release.ts View on Github external
if (!argv.dry) fail(colors.red("Cannot continue, the local branch is behind the remote changes!"));
	else console.log(colors.red("This is a dry run. The full run would fail due to the local branch being behind\n"));
} else if (/Your branch is up\-to\-date/.test(gitStatus) || /Your branch is ahead/.test(gitStatus)) {
	// all good
	console.log(colors.green("git status is good - I can continue..."));
}

const releaseTypes = ["major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease"];

const releaseType = argv._[0] || "patch";
let newVersion = releaseType;
const oldVersion = pack.version as string;
if (releaseTypes.indexOf(releaseType) > -1) {
	if (releaseType.startsWith("pre") && argv._.length >= 2) {
		// increment to pre-release with an additional prerelease string
		newVersion = semver.inc(oldVersion, releaseType, argv._[1]);
	} else {
		newVersion = semver.inc(oldVersion, releaseType);
	}
	console.log(`bumping version ${colors.blue(oldVersion)} to ${colors.gray(releaseType)} version ${colors.green(newVersion)}\n`);
} else {
	// increment to specific version
	newVersion = semver.clean(newVersion);
	if (newVersion == null) {
		fail(`invalid version string "${newVersion}"`);
	} else {
		// valid version string => check if its actually newer
		if (!semver.gt(newVersion, pack.version)) {
			fail(`new version ${newVersion} is NOT > than package.json version ${pack.version}`);
		}
		// if (!semver.gt(newVersion, ioPack.common.version)) {
		// 	fail(`new version ${newVersion} is NOT > than io-package.json version ${ioPack.common.version}`);
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 saucelabs / speedo / src / commands / run.js View on Github external
export const handler = async (argv) => {
    const config = getConfig(argv)
    const username = config.user || process.env.SAUCE_USERNAME
    const accessKey = config.key || process.env.SAUCE_ACCESS_KEY
    const jobName = getJobName(config)
    const buildName = config.build || `${jobName} - ${(new Date()).toString()}`
    const budget = config ? config.budget : null
    const metrics = budget ? getBudgetMetrics(budget) : getMetricParams(config)
    const jankinessScore = getJankinessParam(argv, budget)
    /**
     * check if username and access key are available
     */
    if (!username || !accessKey) {
        yargs.showHelp()
        // eslint-disable-next-line no-console
        console.error(ERROR_MISSING_CREDENTIALS)
        return process.exit(1)
    }

    const status = ora(`Start performance test run with user ${username} on page ${config.site}...`).start()

    const logDir = config.logDir
        ? path.resolve(process.cwd(), config.logDir)
        : tmp.dirSync().name

    /**
     * check if job already exists
     */
    const user = new SauceLabs({
        user: username,
github NorthMcCormick / Polyonic / tasks / run.js View on Github external
gulp.task('run', function(error) {
  if(argv.prod !== undefined) {
    console.log('Starting app from "build" without live-reload...')
    childProcess.spawn(electron, ['./build'], {
      stdio: 'inherit'
    })
    .on('close', function () {
        // User closed the app. Kill the host process.
      process.exit()
    })
  }else{
    console.log('Starting app from "src" with live-reload...')
    var runner = childProcess.exec('cd src && gulp dev', function (error, stdout, stderr) {
      console.log(stdout);
      console.log(stderr);

      done(error);
    });
github openaps / oref0 / bin / oref0-determine-basal.js View on Github external
full terms and conditions

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
*/

/* istanbul ignore next */
if (!module.parent) {
    var determinebasal = init();

    var argv = require('yargs')
      .usage("$0 iob.json currenttemp.json glucose.json profile.json [[--auto-sens] autosens.json] [meal.json] [--reservoir reservoir.json]")
      .option('auto-sens', {
        alias: 'a',
        describe: "Auto-sensitivity configuration",
        default: true

      })
      .option('reservoir', {
        alias: 'r',
        describe: "Reservoir status file for SuperMicroBolus mode (oref1)",
        default: false

      })
      .option('meal', {
        describe: "json doc describing meals",
        default: true
github naver / ngrinder / ngrinder-frontend / webpack.config.js View on Github external
var argv = require('yargs').argv;
var productionBuild = argv.p || false;
var devMode = process.env.NODE_ENV !== 'production';

if (productionBuild) {
    console.log('### production build is enabled. ga is included and javascript is optmized\r');
} else {
    console.log('### production build is disabled.\r');
}

if (argv.w || argv.watch) {
    console.log('### watch is enabled');
}
// If we omit the following line, the env var for module.exports will be undefined. It's weired.
console.log('### passed env is ' + JSON.stringify(argv.env));

module.exports = function (env) {
    var ngrinderVersion = '3.5.0-SNAPSHOT';
    if (env !== undefined && env.ngrinderVersion !== undefined) {
        ngrinderVersion = env.ngrinderVersion;
    }
    console.log('### frontend version is ' + ngrinderVersion + '\r');

    var webpackConfig = {
        mode: 'production',
        performance: {
            hints: false,
        },
        entry: { 'app': ['@babel/polyfill', 'entries/app.js']},
        output: {
            path: outputDir,