MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / parseArgs

Function parseArgs

scripts/static-server.mjs:80–173  ·  view source on GitHub ↗
(argv = process.argv.slice(2))

Source from the content-addressed store, hash-verified

78// ─────────────────────────────────────────────────────────────────────────────
79
80export function parseArgs(argv = process.argv.slice(2)) {
81 const config = {
82 port: 3001,
83 host: "::",
84 dir: "build",
85 routes: {},
86 rejectPrefixes: [],
87 sessionApiKey: null,
88 authRequired: false,
89 runtimeServicesInfo: null,
90 lockToCloud: null,
91 basePath: "/",
92 };
93
94 for (let i = 0; i < argv.length; i++) {
95 const flag = argv[i];
96 switch (flag) {
97 case "-p":
98 case "--port":
99 config.port = Number.parseInt(argv[++i], 10);
100 break;
101 case "-H":
102 case "--host":
103 config.host = argv[++i];
104 break;
105 case "-d":
106 case "--dir":
107 config.dir = argv[++i];
108 break;
109 case "-r":
110 case "--route": {
111 const value = argv[++i];
112 const eq = value.indexOf("=");
113 if (eq < 0) {
114 throw new Error(`Invalid --route (expected /prefix=url): ${value}`);
115 }
116 const prefix = value.slice(0, eq);
117 const url = value.slice(eq + 1);
118 if (!prefix.startsWith("/")) {
119 throw new Error(`--route prefix must start with '/': ${prefix}`);
120 }
121 config.routes[prefix] = url;
122 break;
123 }
124 case "--session-api-key":
125 config.sessionApiKey = argv[++i] || null;
126 break;
127 case "--runtime-services-info":
128 config.runtimeServicesInfo = argv[++i] || null;
129 break;
130 case "--lock-to-cloud":
131 config.lockToCloud = argv[++i] || null;
132 break;
133 case "--base-path":
134 config.basePath = normalizeBasePath(argv[++i]);
135 break;
136
137 case "--auth-required":

Callers 1

static-server.mjsFile · 0.70

Calls 3

errorMethod · 0.80
normalizeBasePathFunction · 0.70
showHelpFunction · 0.70

Tested by

no test coverage detected