当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ArgumentParser.addArgument方法代码示例

本文整理汇总了TypeScript中argparse.ArgumentParser.addArgument方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ArgumentParser.addArgument方法的具体用法?TypeScript ArgumentParser.addArgument怎么用?TypeScript ArgumentParser.addArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在argparse.ArgumentParser的用法示例。


在下文中一共展示了ArgumentParser.addArgument方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: instrumentApp

function instrumentApp(args: Array<string>): void {
    var parser = new argparse.ArgumentParser({
        prog: "meminsight instrument",
        addHelp: true,
        description: "instrument a local application"
    });
    parser.addArgument(['--outputDir'], { help:"directory in which to place instrumented files and traces.  " +
    "We create a new sub-directory for our output.", defaultValue: "/tmp" });
    parser.addArgument(['--only_include'], { help:"list of path prefixes specifying which sub-directories should be instrumented, separated by path.delimiter"});
    parser.addArgument(['path'], { help:"directory of app to instrument" });
    var parsed = parser.parseArgs(args);
    var appPath = parsed.path;
    var outputDir = parsed.outputDir;

    console.log("instrumenting app " + appPath);
    if (!fs.existsSync(appPath)) {
        console.error("path " + appPath + " does not exist");
        process.exit(1);
    }
    var cliArgs = [
        path.join(__dirname, 'memTraceDriver.js'),
        '--justGenerate',
        '--verbose',
        '--outputDir',
        outputDir
    ];
    if (parsed.only_include) {
        cliArgs.push('--only_include', parsed.only_include);
    }
    cliArgs.push(appPath);
    runNodeProg(cliArgs, "instrumentation");
}
开发者ID:KrupaR,项目名称:meminsight,代码行数:32,代码来源:meminsight.ts

示例2: instAndRunNodeScript

/**
 * run memory analysis on node script using on-the-fly instrumentation
 * @param args
 */
function instAndRunNodeScript(args: Array<string>): void {
    var parser = new argparse.ArgumentParser({
        prog: "meminsight nodeinstrun",
        addHelp: true,
        description: "instrument a node.js script as it runs and collect profiling results"
    });
    parser.addArgument(['script'], { help: "path of script to run, relative to appPath"});
    parser.addArgument(['scriptArgs'], {
        help: "command-line arguments to pass to script",
        nargs: argparse.Const.REMAINDER
    });
    var parsed = parser.parseArgs(args);
    var script = path.resolve(parsed.script);
    var scriptArgs = parsed.scriptArgs;
    // dump traces in same directory as the instrumented script
    // TODO make this configurable
    var appPath = path.dirname(script);
    var curDir = process.cwd();
    process.chdir(appPath);
    console.log("running node.js script " + script);
    var loggingAnalysisArgs = [
        onTheFlyDriver,
        '--inlineIID',
        '--analysis',
        loggingAnalysis,
        '--initParam',
        'syncFS:true',
        '--astHandlerModule',
        path.join(__dirname, '..', 'lib', 'analysis', 'freeVarsAstHandler.js'),
        script].concat(scriptArgs);
    runNodeProg(loggingAnalysisArgs, "run of script ", (code: number) => {
        if (code !== 0) {
            console.log("run of script failed");
            return;
        }
        console.log("run of script complete");
        // run the lifetime analysis
        var javaProc = lifetimeAnalysis.runLifetimeAnalysisOnTrace(path.join(appPath,'mem-trace'));
        javaProc.stdout.on("data", (chunk : any) => {
            console.log(chunk.toString());
        });
        javaProc.stderr.on("data", (chunk : any) => {
            console.error(chunk.toString());
        });
        javaProc.on("exit", () => {
            console.log("done with lifetime analysis");
        });

    });

}
开发者ID:KrupaR,项目名称:meminsight,代码行数:55,代码来源:meminsight.ts

示例3: inspectApp

function inspectApp(args: Array<string>): void {
    var parser = new argparse.ArgumentParser({
        prog: "meminsight inspect",
        addHelp: true,
        description: "inspect results of a previous profiling run"
    });
    parser.addArgument(['path'], { help:"directory of instrumented app" });
    var parsed = parser.parseArgs(args);
    var appPath = parsed.path;

    console.log("inspecting previous run of app " + appPath);
    if (!fs.existsSync(appPath)) {
        console.error("path " + appPath + " does not exist");
        process.exit(1);
    }
    // in order to inspect, we must have a staleness.json and
    // enhanced-trace file present
    var stalenessTrace = path.join(appPath, 'staleness-trace');
    if (!fs.existsSync(stalenessTrace)) {
        console.error("no staleness trace from previous run present; exiting");
        process.exit(1);
    }
    // OK, we have the files.  run the GUI server
    var cliArgs = [
        path.join(__dirname, '..', 'lib', 'gui', 'guiServer.js'),
        appPath
    ];
    runNodeProg(cliArgs, "inspect of app ");
}
开发者ID:KrupaR,项目名称:meminsight,代码行数:29,代码来源:meminsight.ts

示例4: runApp

function runApp(args: Array<string>): void {
    var parser = new argparse.ArgumentParser({
        prog: "meminsight run",
        addHelp: true,
        description: "run an instrumented web app and collect profiling results"
    });
    parser.addArgument(['path'], { help:"directory of instrumented app" });
    var parsed = parser.parseArgs(args);
    var appPath = parsed.path;
    console.log("running app " + appPath);
    if (!fs.existsSync(appPath)) {
        console.error("path " + appPath + " does not exist");
        process.exit(1);
    }
    var cliArgs = [
        path.join(__dirname, '..', 'lib', 'server', 'server.js'),
        appPath
    ];
    runNodeProg(cliArgs, "run of app ");
}
开发者ID:KrupaR,项目名称:meminsight,代码行数:20,代码来源:meminsight.ts

示例5: originIsAllowed

/**
 * utility function used by the websocket server.
 * currently does nothing
 */
function originIsAllowed(origin: string) {
    // put logic here to detect whether the specified origin is allowed.
    return true;
}

var argparse = require('argparse');
var parser = new argparse.ArgumentParser({
    addHelp: true,
    description: "Integrated server for memory profiler"
});
parser.addArgument(['--proxy'], { help: "run as a proxy server, instrumenting code on-the-fly", action:'storeTrue' });
parser.addArgument(['--proxyOutput'], { help: "in proxy server mode, directory under which to store instrumented code", defaultValue: '/tmp/proxyOut' });
parser.addArgument(['--noHTTPServer'], { help: "don't start up a local HTTP server", action: 'storeTrue'});
parser.addArgument(['--outputFile'], { help: "name for output file for memory trace (default mem-trace in app directory)" });
parser.addArgument(['app'], { help: "the app to serve.  in proxy mode, the app should be uninstrumented.", nargs: 1});
var args: { proxy: string; proxyOutput: string; noHTTPServer: string; app: Array<string>; outputFile: string; } = parser.parseArgs();

var app = args.app[0];

// default to app directory; we'll change it in proxy server mode
var outputDir = app;

/**
 * create a fresh directory in which to dump instrumented scripts
 */
function initProxyOutputDir(): void {
开发者ID:crudbug,项目名称:meminsight,代码行数:30,代码来源:server.ts

示例6: Fatal

  if (ret !== undefined) {
    return ret;
  }

  throw new Fatal(`cannot parse ${name}`);
}

const parser = new ArgumentParser({
  addHelp: true,
  description: "Generates a JSON file suitable for using as the " +
    "``metadata`` option for a generic Meta object. The input file must " +
    "be a JSON file in the format produced by TEI's odd2json.xsl " +
    "transformation.",
});

parser.addArgument(["input"],
                   { help: "Input file." });

parser.addArgument(["output"], {
  help: "Output file. If absent, outputs to stdout.",
  nargs: "?",
});

parser.addArgument(["--tei"], {
  help: "Treat the input as a TEI JSON file produced by TEI's odd2json.xsl.",
  action: "storeTrue",
});

parser.addArgument(["-p", "--pretty"], {
  help: "Pretty print the final JSON.",
  action: "storeTrue",
});
开发者ID:lddubeau,项目名称:wed,代码行数:32,代码来源:wed-metadata.ts

示例7: ArgumentParser

// near copy of each of the tests from https://github.com/nodeca/argparse/tree/master/examples

import {ArgumentParser, RawDescriptionHelpFormatter} from 'argparse';
var args: any;

var simpleExample = new ArgumentParser({
  version: '0.0.1',
  addHelp: true,
  description: 'Argparse example',
});
simpleExample.addArgument(
  ['-f', '--foo'],
  {
    help: 'foo bar',
  }
);
simpleExample.addArgument(
  ['-b', '--bar'],
  {
    help: 'bar foo',
  }
);

simpleExample.printHelp();
console.log('-----------');

args = simpleExample.parseArgs('-f 1 -b2'.split(' '));
console.dir(args);
console.log('-----------');
args = simpleExample.parseArgs('-f=3 --bar=4'.split(' '));
开发者ID:ArtemZag,项目名称:DefinitelyTyped,代码行数:30,代码来源:argparse-tests.ts

示例8: require

/**
 * Created by m.sridharan on 6/16/14.
 */

import mkdirp = require('mkdirp');
import path = require('path');
import fs = require('fs');
import memTracer = require('../lib/analysis/memTraceAPI');
import Q = require('q');
var argparse = require('argparse');
var parser = new argparse.ArgumentParser({
    addHelp: true,
    description: "Command-line utility to generate memory trace"
});
parser.addArgument(['--debugFun'], { help: "function name for debug logging" });
parser.addArgument(['--only_include'], { help:"list of path prefixes specifying which sub-directories should be instrumented, separated by path.delimiter"});
parser.addArgument(['--syncAjax'], { help: "use synchronous AJAX calls for logging", action:'storeTrue' });
parser.addArgument(['--outputDir'], { help:"directory in which to place instrumented files and traces.  " +
                                           "We create a new sub-directory for our output.", required:true });
parser.addArgument(['--justGenerate'], { help: "just instrument and generate metadata, but don't produce mem-trace", action: 'storeTrue'});
parser.addArgument(['--verbose'], { help: "print verbose output", action:'storeTrue'});
parser.addArgument(['inputFile'], { help:"Either a JavaScript file or an HTML app directory with an index.html file" });
var args = parser.parseArgs();
var outputDir:string = args.outputDir;

var jsFile: boolean = !fs.statSync(args.inputFile).isDirectory();
var promise : Q.Promise<any>, trueOutputDir: string;
if (jsFile) {
    var script = args.inputFile;
    trueOutputDir = path.join(outputDir,path.basename(script, '.js')+"_inst");
开发者ID:KrupaR,项目名称:meminsight,代码行数:30,代码来源:memTraceDriver.ts

示例9: function

module.exports.parseArgs = function() {
  const parser = new ArgumentParser({
    version: pjson.version,
    addHelp: true,
    description: 'BitGo-Express'
  });

  parser.addArgument(['-p', '--port'], {
    defaultValue: 3080,
    type: 'int',
    help: 'Port to listen on'
  });

  parser.addArgument(['-b', '--bind'], {
    defaultValue: 'localhost',
    help: 'Bind to given address to listen for connections (default: localhost)'
  });

  parser.addArgument(['-e', '--env'], {
    defaultValue: 'test',
    help: 'BitGo environment to proxy against (prod, test)'
  });

  parser.addArgument(['-d', '--debug'], {
    action: 'appendConst',
    dest: 'debugnamespace',
    constant: 'bitgo:express',
    help: 'Enable basic debug logging for incoming requests'
  });

  parser.addArgument(['-D', '--debugnamespace'], {
    action: 'append',
    help: 'Enable a specific debugging namespace for more fine-grained debug output. May be given more than once.'
  });

  parser.addArgument(['-k', '--keypath'], {
    help: 'Path to the SSL Key file (required if running production)'
  });

  parser.addArgument(['-c', '--crtpath'], {
    help: 'Path to the SSL Crt file (required if running production)'
  });

  parser.addArgument( ['-u', '--customrooturi'], {
    defaultValue: process.env.BITGO_CUSTOM_ROOT_URI,
    help: 'Force custom root BitGo URI (e.g. https://test.bitgo.com)'
  });

  parser.addArgument(['-n', '--custombitcoinnetwork'], {
    defaultValue: process.env.BITGO_CUSTOM_BITCOIN_NETWORK,
    help: 'Force custom bitcoin network (e.g. testnet)'
  });

  parser.addArgument(['-l', '--logfile'], {
    help: 'Filepath to write the access log'
  });

  parser.addArgument(['--disablessl'], {
    action: 'storeTrue',
    help: 'Allow running against production in non-SSL mode (at your own risk!)'
  });

  parser.addArgument(['--disableproxy'], {
    action: 'storeTrue',
    help: 'disable the proxy, not routing any non-express routes'
  });

  parser.addArgument(['--disableenvcheck'], {
    action: 'storeTrue',
    defaultValue: true, // BG-9584: temporarily disable env check while we give users time to react to change in runtime behavior
    help: 'disable checking for proper NODE_ENV when running in prod environment'
  });

  parser.addArgument(['-t', '--timeout'], {
    defaultValue: (process.env.BITGO_TIMEOUT as any) * 1000 || DEFAULT_TIMEOUT,
    help: 'Proxy server timeout in milliseconds'
  });

  return parser.parseArgs();
};
开发者ID:BitGo,项目名称:BitGoJS,代码行数:80,代码来源:expressApp.ts

示例10: ArgumentParser

  throw ex;
});

//
// The real logic begins here.
//

const parser = new ArgumentParser({
  addHelp: true,
  description: "Converts a simplified RNG file to a JavaScript file " +
    "that salve can use.",
});

parser.addArgument(["--version"], {
  help: "Show program's version number and exit.",
  action: "version",
  version,
} as any);

const availableSimplifiers = getAvailableSimplifiers();
if (!availableSimplifiers.includes("internal")) {
  throw new Fatal("internal must be among the available validators");
}

parser.addArgument(["--simplifier"], {
  help: "Select the schema simplifier.",
  choices: availableSimplifiers,
  defaultValue: "internal",
});

const availableValidators = getAvailableValidators();
开发者ID:lddubeau,项目名称:salve,代码行数:31,代码来源:convert.ts


注:本文中的argparse.ArgumentParser.addArgument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。