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


TypeScript ArgumentParser.parseArgs方法代码示例

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


在下文中一共展示了ArgumentParser.parseArgs方法的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: 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

示例3: parseArgs

export function parseArgs(args?: string[]):
    {appDir: string, runtimeImage: string} {
  const parsedArgs = PARSER.parseArgs(args);
  return {
    appDir: parsedArgs.app_dir[0],
    runtimeImage: parsedArgs.runtime_image[0]
  };
}
开发者ID:GoogleCloudPlatform,项目名称:nodejs-docker,代码行数:8,代码来源:main.ts

示例4: 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

示例5: 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

示例6: ArgumentParser

}

const parser = new ArgumentParser({
    description: 'CLI interface for the ehBasic hardware monitor',
    addHelp: true
});

parser.addArgument('--cpu-type', {
    help: `one of ${CpuTypes.stateMachine} (default), ${CpuTypes.batchedAccess}`,
    choices: [CpuTypes.stateMachine, CpuTypes.batchedAccess],
    defaultValue: CpuTypes.stateMachine
});
parser.addArgument(['--script', '-s'], { help: 'debugger script' });
parser.addArgument(['--file', '-f'], { help: 'input to feed into the monitor' });

const args = parser.parseArgs();

const fsProvider = new NodeFilesystemProvider(),
    cli = new EhBasicCLI(fsProvider, cpuType(args['cpu_type'])),
    runner = new NodeCLIRunner(cli);

runner.startup();

if (args['script']) {
    cli.runDebuggerScript(args['script']);
}

if (args['file']) {
    cli.readInputFile(args['file']);
}
开发者ID:DirtyHairy,项目名称:6502.ts,代码行数:30,代码来源:ehBasicCLI.ts

示例7: require

import fs = require("fs")
import Q = require("q")
import cp = require('child_process');
import lastUseTree = require("./lastUseTree")
import issueFinder = require('./issueFinder');
var ejs = require("ejs");

var argparse = require('argparse');
var parser = new argparse.ArgumentParser({
    addHelp: true,
    description: "GUI server for memory profiler"
});

parser.addArgument(['-P', '--port'], { help: "Port to serve on" });
parser.addArgument(['lifetimeDir'], { help: "directory containing lifetime analysis output for app" });
var args: { port: string; lifetimeDir: string } = parser.parseArgs();


var instOptions = {
    iidMap : true,
    serialize : true,
    relative: true
};

var traceDirectory = path.resolve(args.lifetimeDir);
var stalenessTrace = path.join(traceDirectory, 'staleness-trace');
var lastUseTrace = path.join(traceDirectory, 'lastuse-trace');
var unreachableTrace = path.join(traceDirectory, 'unreachable-trace');
var memTrace = path.join(traceDirectory, 'mem-trace');
var port = args.port === null ? 9000 : parseInt(args.port);
开发者ID:crudbug,项目名称:meminsight,代码行数:30,代码来源:guiServer.ts

示例8: originIsAllowed

 * 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(['--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.  if --noHTTPServer is passed, directory of the uninstrumented app, or where app code will be stored (if a proxy server is being used)", nargs: 1});
var args: { noHTTPServer: string; app: Array<string>; outputFile: string; } = parser.parseArgs();

var app = args.app[0];

var outputDir = app;

/**
 * initializes the output target, both a Java process and a WriteStream for a file
 */
function initOutputTarget(): void {
    if (!outputStream) {
        var outputFileName = args.outputFile;
        if (!outputFileName) {
            outputFileName = path.join(outputDir, 'mem-trace');
        }
        outputStream = fs.createWriteStream(outputFileName);
开发者ID:KrupaR,项目名称:meminsight,代码行数:31,代码来源:server.ts

示例9: mkdirSync

        type: "string",
        help: "output filename prefix",
        defaultValue: "ts-"
    }
);
parser.addArgument(
    ["-w", "--watch"],
    {
        defaultValue: args.watch,
        dest: "watch",
        action: "storeTrue",
        help: "Watch source definitions"
    }
);

var parsedArgs: IOptions = parser.parseArgs();
if (parsedArgs.inputs) {
    args.inputs = parsedArgs.inputs;
}
if (parsedArgs.outdir) {
    args.outdir = parsedArgs.outdir;
}

// create out dir
try {
    mkdirSync(args.outdir);
}
catch (e) {
}

// inference rootdir
开发者ID:Perlmint,项目名称:TypedSequelize,代码行数:31,代码来源:cli.ts

示例10: originIsAllowed

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 {
    outputDir = args.proxyOutput;
    var scriptDirToTry = "";
    for (var i = 0; i < 100; i++) {
        scriptDirToTry = path.join(outputDir, "/site" + i);
        if (!fs.existsSync(scriptDirToTry)) {
开发者ID:crudbug,项目名称:meminsight,代码行数:31,代码来源:server.ts


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