@ppdocs/mcp 2.8.4 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +33 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -14,19 +14,50 @@ function parseArgs(args) {
|
|
|
14
14
|
for (let i = 0; i < args.length; i++) {
|
|
15
15
|
const arg = args[i];
|
|
16
16
|
if (arg === '-p' || arg === '--project') {
|
|
17
|
+
if (i + 1 >= args.length || args[i + 1].startsWith('-')) {
|
|
18
|
+
console.error('Error: -p/--project requires a value');
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
17
21
|
opts.project = args[++i];
|
|
18
22
|
}
|
|
19
23
|
else if (arg === '-k' || arg === '--key') {
|
|
24
|
+
if (i + 1 >= args.length || args[i + 1].startsWith('-')) {
|
|
25
|
+
console.error('Error: -k/--key requires a value');
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
20
28
|
opts.key = args[++i];
|
|
21
29
|
}
|
|
22
30
|
else if (arg === '-u' || arg === '--user') {
|
|
31
|
+
if (i + 1 >= args.length || args[i + 1].startsWith('-')) {
|
|
32
|
+
console.error('Error: -u/--user requires a value');
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
23
35
|
opts.user = args[++i];
|
|
24
36
|
}
|
|
25
37
|
else if (arg === '--port') {
|
|
26
|
-
|
|
38
|
+
if (i + 1 >= args.length || args[i + 1].startsWith('-')) {
|
|
39
|
+
console.error('Error: --port requires a value');
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const portVal = parseInt(args[++i], 10);
|
|
43
|
+
if (isNaN(portVal) || portVal < 1 || portVal > 65535) {
|
|
44
|
+
console.error('Error: --port must be a valid port number (1-65535)');
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
opts.port = portVal;
|
|
27
48
|
}
|
|
28
49
|
else if (arg === '--api') {
|
|
29
|
-
|
|
50
|
+
if (i + 1 >= args.length || args[i + 1].startsWith('-')) {
|
|
51
|
+
console.error('Error: --api requires a value');
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const apiVal = args[++i].trim();
|
|
55
|
+
if (!apiVal) {
|
|
56
|
+
console.error('Error: --api value cannot be empty');
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
// 移除用户可能误加的协议前缀
|
|
60
|
+
opts.api = apiVal.replace(/^https?:\/\//, '');
|
|
30
61
|
}
|
|
31
62
|
else if (arg === '--codex') {
|
|
32
63
|
opts.codex = true;
|