MCPcopy
hub / github.com/nestjs/nest / parseArgs

Function parseArgs

tools/benchmarks/src/main.ts:38–80  ·  view source on GitHub ↗
(argv: string[])

Source from the content-addressed store, hash-verified

36}
37
38function parseArgs(argv: string[]): Args {
39 const args: Args = { ...DEFAULTS };
40
41 for (let i = 0; i < argv.length; i++) {
42 const token = argv[i];
43
44 if (token === '--verbose' || token === '-v') {
45 args.verbose = true;
46 continue;
47 }
48
49 if (token === '--connections' || token === '-c') {
50 args.connections = parseNumber(argv[++i], args.connections);
51 continue;
52 }
53
54 if (token === '--duration' || token === '-d') {
55 args.duration = parseNumber(argv[++i], args.duration);
56 continue;
57 }
58
59 if (token === '--pipelining' || token === '-p') {
60 args.pipelining = parseNumber(argv[++i], args.pipelining);
61 continue;
62 }
63
64 if (token === '--port') {
65 args.port = parseNumber(argv[++i], args.port);
66 continue;
67 }
68
69 if (token === '--path') {
70 args.path = argv[++i] ?? args.path;
71 continue;
72 }
73
74 if (token === '--help' || token === '-h') {
75 printHelpAndExit(0);
76 }
77 }
78
79 return args;
80}
81
82function printHelpAndExit(code: number): never {
83 // Keep this simple so `npm run benchmarks` works without extra args.

Callers 1

mainFunction · 0.85

Calls 2

parseNumberFunction · 0.85
printHelpAndExitFunction · 0.85

Tested by

no test coverage detected