How to use the argparse.ArgumentParser function in argparse

To help you get started, we’ve selected a few argparse 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 material-components / material-components-web / test / screenshot / infra / lib / cli.js View on Github external
constructor() {
    /**
     * @type {!ArgumentParser}
     * @private
     */
    this.rootParser_ = new argparse.ArgumentParser({
      // argparse throws an error if `process.argv[1]` is undefined, which happens when you run `node --interactive`.
      prog: process.argv[1] || 'node',
    });

    /**
     * @type {!ActionSubparsers}
     * @private
     */
    this.commandParsers_ = this.rootParser_.addSubparsers({
      title: 'Commands',
    });

    this.initApproveCommand_();
    this.initBuildCommand_();
    this.initCleanCommand_();
    this.initDemoCommand_();
github tensorflow / tfjs-examples / visualize-convnet / main.js View on Github external
function parseArguments() {
  const parser =
      new argparse.ArgumentParser({description: 'Visualize convnet'});
  parser.addArgument('modelJsonUrl', {
    type: 'string',
    help: 'URL to model JSON. Can be a file://, http://, or https:// URL'
  });
  parser.addArgument('convLayerNames', {
    type: 'string',
    help: 'Names of the conv2d layers to visualize, separated by commas ' +
        'e.g., (block1_conv1,block2_conv1,block3_conv1,block4_conv1)'
  });
  parser.addArgument('--inputImage', {
    type: 'string',
    defaultValue: '',
    help: 'Path to the input image. If specified, will compute the internal' +
        'activations of the specified convolutional layers. If not specified, ' +
        'will compute the maximally-activating input images using gradient ascent.'
  });
github rethinkdb / horizon / cli / src / migrate.js View on Github external
function processConfig(cmdArgs) {
  // do boilerplate to get config args :/
  const parser = new argparse.ArgumentParser({ prog: 'hz migrate' });

  parser.addArgument([ 'project_path' ], {
    default: '.',
    nargs: '?',
    help: 'Change to this directory before migrating',
  });

  parser.addArgument([ '--project-name', '-n' ], {
    help: 'Name of the Horizon project server',
  });

  parser.addArgument([ '--connect', '-c' ], {
    metavar: 'host:port',
    default: undefined,
    help: 'Host and port of the RethinkDB server to connect to.',
  });
github mozilla / DeepSpeech / native_client / javascript / client.js View on Github external
options.nargs = 0;
  argparse.Action.call(this, options);
}
util.inherits(VersionAction, argparse.Action);

VersionAction.prototype.call = function(parser) {
  Ds.printVersions();
  let runtime = 'Node';
  if (process.versions.electron) {
    runtime = 'Electron';
  }
  console.error('Runtime: ' + runtime);
  process.exit(0);
}

var parser = new argparse.ArgumentParser({addHelp: true, description: 'Running DeepSpeech inference.'});
parser.addArgument(['--model'], {required: true, help: 'Path to the model (protocol buffer binary file)'});
parser.addArgument(['--lm'], {help: 'Path to the language model binary file', nargs: '?'});
parser.addArgument(['--trie'], {help: 'Path to the language model trie file created with native_client/generate_trie', nargs: '?'});
parser.addArgument(['--audio'], {required: true, help: 'Path to the audio file to run (WAV format)'});
parser.addArgument(['--beam_width'], {help: 'Beam width for the CTC decoder', defaultValue: 500, type: 'int'});
parser.addArgument(['--lm_alpha'], {help: 'Language model weight (lm_alpha)', defaultValue: 0.75, type: 'float'});
parser.addArgument(['--lm_beta'], {help: 'Word insertion bonus (lm_beta)', defaultValue: 1.85, type: 'float'});
parser.addArgument(['--version'], {action: VersionAction, help: 'Print version and exits'});
parser.addArgument(['--extended'], {action: 'storeTrue', help: 'Output string from extended metadata'});
var args = parser.parseArgs();

function totalTime(hrtimeValue) {
  return (hrtimeValue[0] + hrtimeValue[1] / 1000000000).toPrecision(4);
}

function metadataToString(metadata) {
github thiagobustamante / typescript-rest-swagger / src / cli.ts View on Github external
import * as ts from 'typescript';
import * as YAML from 'yamljs';
import { Config, Specification, SwaggerConfig } from './config';
import { MetadataGenerator } from './metadata/metadataGenerator';
import { SpecGenerator } from './swagger/generator';

const debugLog = debug('typescript-rest-swagger');
const packageJson = require(`../package.json`);

const workingDir: string = process.cwd();
const versionDefault = getPackageJsonValue('version');
const nameDefault = getPackageJsonValue('name');
const descriptionDefault = getPackageJsonValue('description');
const licenseDefault = getPackageJsonValue('license');

const parser = new ArgumentParser({
    addHelp: true,
    description: 'Typescript-REST Swagger tool',
    version: packageJson.version
});

parser.addArgument(
    ['-c', '--config'],
    {
        help: 'The swagger config file (swagger.json or swagger.yml).'
    }
);

parser.addArgument(
    ['-t', '--tsconfig'],
    {
        action: 'storeTrue',
github fontello / svg-font-create / svg-font-create.js View on Github external
'<% _.forEach(glyphs, function(glyph) { %>' +
      '\n' +
    '<% }); %>' +

    '\n' +
    '\n' +
    ''
  );


var parser = new ArgumentParser({
  version: require('./package.json').version,
  addHelp: true,
  description: 'Create SVG font from separate images'
});
parser.addArgument([ '-c', '--config' ], { help: 'Font config file', required: true });
parser.addArgument([ '-i', '--input_dir' ], { help: 'Source images path', required: true });
parser.addArgument([ '-o', '--output' ], { help: 'Output font file path', required: true });
parser.addArgument([ '-s', '--svgo_config' ], { help: 'SVGO config path (use default if not set)' });

var args = parser.parseArgs();

////////////////////////////////////////////////////////////////////////////////


var config, tmpDir;
github fontello / svg2ttf / svg2ttf.js View on Github external
Written for fontello.com project.
 */

/*eslint-disable no-console*/

'use strict';


var fs = require('fs');
var ArgumentParser = require('argparse').ArgumentParser;

var svg2ttf = require('./');


var parser = new ArgumentParser({
  version: require('./package.json').version,
  addHelp: true,
  description: 'SVG to TTF font converter'
});

parser.addArgument(
  [ '-c', '--copyright' ],
  {
    help: 'Copyright text',
    required: false
  }
);

parser.addArgument(
  [ '-d', '--description' ],
  {
github develephant / phaser-node-kit / cli.js View on Github external
* @copyright (c)2017 develephant.com
 * @license MIT
 * https://github.com/develephant/phaser-node-kit
 */
const pkg = require('./package')
const ArgParser = require('argparse').ArgumentParser

const Build = require('./lib/build')
const Watch = require('./lib/watch')
const Update = require('./lib/update')

const builder = new Build()
const watcher = new Watch()
const updater = new Update()

const parser = new ArgParser({
  description: 'Phaser Node Kit',
  version: pkg.version,
  allowAbbrev: false,
  epilog: '(c)2017 develephant.com'
})

parser.addArgument('action', {
  help: 'Phaser Node Kit Actions',
  choices: [
    'init',
    'watch',
    'sync',
    'update'
  ]
})
github nos / create-nos-dapp / src / utils / argParser.js View on Github external
import { ArgumentParser } from "argparse";
const { version } = require("./../../package.json");

const argParser = new ArgumentParser({
  addHelp: true,
  description: "create-nos-dapp",
  usage: "create-nos-dapp [-h] [-v] [-t TYPE] [-n NAME]",
  version,
});

argParser.addArgument(["-t", "--type"], {
  help: "Template type (react/vanilla/vue)",
});
argParser.addArgument(["-n", "--name"], {
  help: "Project name, f.e. my-nos-dapp",
});

export default argParser;
github uber / streetscape.gl / examples / converters / nutonomy / src / args.js View on Github external
const {ArgumentParser} = require('argparse');
const path = require('path');

const parser = new ArgumentParser({
  addHelp: true,
  description: 'NuTonomy to XVIZ converter'
});

parser.addArgument(['-d', '--data-directory'], {
  required: true,
  help: 'Path to raw KITTI data. Relative path will be resolved relative to /data/kitti/'
});

parser.addArgument(['-o', '--output'], {
  help: 'Path to generated data. Relative path will be resolved relative to /data/generated/kitti/'
});

parser.addArgument(['--disable-streams'], {
  defaultValue: '',
  help: 'Comma separated stream names to disable'