• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript argparse.ArgumentParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

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


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


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


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

var javaProc : cp.ChildProcess;
var outputStream: fs.WriteStream;


/**
 * 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
开发者ID:crudbug,项目名称:meminsight,代码行数:32,代码来源:server.ts


示例6: catch

    });
  }
  // tslint:disable-next-line:no-empty
  catch (ex) {}

  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",
开发者ID:lddubeau,项目名称:wed,代码行数:31,代码来源: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

///<reference path='../lib/ts-declarations/jalangi.d.ts' />
///<reference path='../lib/ts-declarations/mkdirp.d.ts' />
///<reference path='../lib/ts-declarations/wrench.d.ts' />

/**
 * 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) {
开发者ID:KrupaR,项目名称:meminsight,代码行数:32,代码来源: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: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript argv.option函数代码示例发布时间:2022-05-25
下一篇:
TypeScript archiver.default函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap