MCPcopy Create free account
hub / github.com/cli/cli / parse

Function parse

evals/src/smoke.ts:35–54  ·  view source on GitHub ↗
(argv: string[])

Source from the content-addressed store, hash-verified

33}
34
35function parse(argv: string[]): Options | undefined {
36 let live = false;
37 let gh = "";
38 let output = "";
39 for (let index = 0; index < argv.length; index++) {
40 const arg = argv[index]!;
41 if (arg === "--help" || arg === "-h") { console.log(usage); return; }
42 if (arg === "--live") live = true;
43 else if (arg === "--gh") gh = argv[++index] ?? "";
44 else if (arg === "--output") output = argv[++index] ?? "";
45 else throw new Error(`Unknown option: ${arg}\n${usage}`);
46 }
47 if (!live) throw new Error(`Live operations require --live.\n${usage}`);
48 if (!gh) throw new Error(`--gh requires an already-built binary.\n${usage}`);
49 return {
50 gh,
51 output: output || join(process.env.XDG_STATE_HOME || join(homedir(), ".local/state"),
52 "gh-event-evals/smoke", new Date().toISOString().replaceAll(":", "-")),
53 };
54}
55
56function waitForExit(child: ChildProcess): Promise<{ code: number | null; signal: NodeJS.Signals | null }> {
57 return new Promise((resolveExit, reject) => {

Callers 1

mainFunction · 0.85

Calls 1

logMethod · 0.80

Tested by

no test coverage detected