How to use the yargs.terminalWidth 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 GoogleChrome / lighthouse / lighthouse-core / scripts / compare-timings.js View on Github external
'measure-filter': 'Regex of measures to include. Optional',
    'output': 'table, json',
    // --compare
    'compare': 'Compare two sets of LHRs',
    'delta-property-sort': 'Property to sort by its delta',
    'desc': 'Set to override default ascending sort',
  })
  .string('measure-filter')
  .default('report-exclude', 'min|max|stdev|^n$')
  .default('delta-property-sort', 'mean')
  .default('output', 'table')
  .array('urls')
  .string('lh-flags')
  .default('desc', false)
  .default('lh-flags', '')
  .wrap(yargs.terminalWidth())
.argv;

const reportExcludeRegex =
  argv.reportExclude !== 'none' ? new RegExp(argv.reportExclude, 'i') : null;

/**
 * @param {string} name
 */
function dir(name) {
  return `${ROOT_OUTPUT_DIR}/${name}`;
}

/**
 * @param {number[]} values
 */
function sum(values) {
github zowe / imperative / packages / utilities / src / TextUtils.ts View on Github external
public static getRecommendedWidth(preferredWidth: number = TextUtils.DEFAULT_WRAP_WIDTH): number {
        const widthSafeGuard = 8; // prevent partial words from continuing over lines
        const yargs = require("yargs");
        const maxWidth = !isNullOrUndefined(yargs.terminalWidth() && yargs.terminalWidth() > 0) ?
            (yargs.terminalWidth() - widthSafeGuard) : preferredWidth;
        return Math.min(preferredWidth, maxWidth);
    }
github pirxpilot / postcss-cli / index.js View on Github external
return [
      'postcss version',
      require('./node_modules/postcss/package.json').version
    ].join(' ');
  }, 'v')
  .alias('v', 'version')
  .help('h')
  .alias('h', 'help')
  .demand(1, 1, 'Please specify a single input file.')
  .check(function(argv) {
    if (!argv.use) {
      throw 'Please specify at least one plugin name.';
    }
    return true;
  })
  .wrap(Math.max(yargs.terminalWidth() - 5, 60))
  .argv;

if (!Array.isArray(argv.use)) {
  argv.use = [argv.use];
}

if (argv.map === 'file') {
  // treat `--map file` as `--no-map.inline`
  argv.map = { inline: false };
}

// load and configure plugin array
var plugins = argv.use.map(function(name) {
  var plugin = require(name);
  if (name in argv) {
    plugin = plugin(argv[name]);
github rolodato / gitlab-letsencrypt / args.js View on Github external
demandOption: true
    }).option('jekyll', {
        describe: 'Upload challenge files with a Jekyll-compatible YAML front matter (see https://jekyllrb.com/docs/frontmatter)',
        type: 'boolean',
        default: false
    }).option('path', {
        describe: 'Absolute path in your repository where challenge files will be uploaded. Your .gitlab-ci.yml file must be configured to serve the contents of this directory under http://YOUR_SITE/.well-known/acme-challenge',
        type: 'string',
        default: '/public/.well-known/acme-challenge'
    }).option('production', {
        describe: 'Obtain a real certificate instead of a dummy one and configure your repository to use it',
        type: 'boolean',
        default: false
    }).example('$0 --domain example.com www.example.com --email rolodato@example.com --repository https://gitlab.com/foo/example.gitlab.io --token abc123', 'Simple build where all files are served from public/ inside your repository')
    .example('$0 --jekyll --path / --domain example.com --email rolodato@example.com --repository https://gitlab.example.com/foo/myrepo --token abc123', 'Jekyll website that serves all valid files in your repository\'s root directory')
    .wrap(yargs.terminalWidth())
    .check(argv => {
        const empty = Object.keys(argv).filter(key => key !== '_' && argv[key].length == 0);
        if (empty.length > 0) {
            console.error(`Missing required arguments: ${empty.join(', ')}`);
            process.exit(1);
        } else {
            return true;
        }
    }).argv;
github yoichiro / actions-tools / src / actions-tools-command.ts View on Github external
})
            }, async (args: yargs.Arguments) => {
                const exitCode = await this._startTesting(
                    args.locale,
                    args.input,
                    args.report,
                    args.credential,
                )
                this._exit(exitCode)
            })
            .fail((msg: string, err: Error) => {
                this._onFail(msg || err.message)
            })
            .version(false)
            .help()
            .wrap(yargs.terminalWidth())
    }
github Rush / publish-to-git / main.js View on Github external
const { publish } = require('./');
const yargs = require('yargs');
const argv = yargs
  .usage('Usage: $0')
  .example('$0 --tag v2.1.3 --no-push     # by default version from package.json is used')
  .example('$0 --remote https://USER:GITHUB_TOKEN@github.com/USER/REPO')
  .example('$0 --force    # useful in CI and when we want to override the same tag which triggered the build')
  .describe('remote', 'Git remote, may be remote name or full URL to the repo')
  .default('remote', 'origin')
  .describe('tag', 'Tag name to which src will be published, for example: v1.2.3 - by default uses version from package.json')
  .describe('push', 'Push update to the git remote (pass --no-push to disable)')
  .describe('force', 'Override any existing tag on the remote as well as locally (git tag -f, git push -f)')
  .boolean('push')
  .boolean('force')
  .default('push', 'true')
  .wrap(yargs.terminalWidth())
  .argv;

const path = require('path');
const packageJson = require(path.join(process.cwd(), '/package.json'));

publish({
  tag: argv.tag,
  name: packageJson.name,
  version: packageJson.version,
  push: argv.push && {
    remote: argv.remote,
    force: argv.force,
  },
  packOptions: {
    verbose: true
  }
github opencomponents / oc / src / cli / index.js View on Github external
);
}

_.forEach(commands.commands, (command, commandName) => {
  processCommand(command, commandName, cli);
});

const argv = cli
  .completion()
  .check(argv => validateCommand(argv, 0))
  .usage(commands.usage)
  .epilogue(strings.messages.cli.HELP_HINT)
  .help('h')
  .alias('h', 'help')
  .version()
  .wrap(cli.terminalWidth()).argv;

if (argv._.length === 0) {
  cli.showHelp();
}
github imodeljs / imodeljs / core / webserver / src / WebServer.ts View on Github external
function getArgs(): yargs.Arguments {
  const args = yargs
    .usage("$0  ")
    .wrap(yargs.terminalWidth())
    .option("port", {
      alias: "p",
      description: "Web Server Port",
      default: 3000,
      type: "number",
    })
    .option("resources", {
      alias: "r",
      description: "Path to resource root directory",
      demandOption: true,
      type: "string",
    }).argv;

  return args;
}
github cryppadotta / dotta-license / dot-license-cli / bin / dot-license-cli.js View on Github external
userdoc: { notice: 'Creates a promotional purchase' },
    },
  },
};

let builder = dotAbiCli(
  yargs,
  path.join(__dirname, '..', 'lib', 'dot-license.abi.json'),
  dotAbiCliConfig
);

builder = builder
  .default('contract-address', process.env.LICENSE_CORE_ADDRESS)
  .demand('contract-address')
  .commandDir(path.join(__dirname, '..', 'lib', 'cmds', 'license'))
  .wrap(yargs.terminalWidth());

if (process.env.KEY_MNEMONIC) {
  let provider = new HDWalletProvider(
    process.env.KEY_MNEMONIC,
    process.env.WEB3_PROVIDER_URL,
    process.env.HD_KEY_IDX ? parseInt(process.env.HD_KEY_IDX) : 0
  );
  provider.engine.addProvider(new NonceTrackerSubprovider());
  builder
    .option('provider', {
      hidden: true,
    })
    .default('provider', provider, '(provider)');
}

process.on('unhandledRejection', (reason, p) => {