@emqo/claudebridge 0.1.2 → 0.1.4
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 +13 -8
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -29,13 +29,15 @@ function removePid() { try {
|
|
|
29
29
|
catch { } }
|
|
30
30
|
const args = process.argv.slice(2);
|
|
31
31
|
if (args.includes("--help") || args.includes("-h")) {
|
|
32
|
-
console.log("Usage: claudebridge <start|stop|status|reload|init> [--config path] [--
|
|
32
|
+
console.log("Usage: claudebridge <start|stop|status|reload|init> [--config path] [--foreground|-f]");
|
|
33
33
|
process.exit(0);
|
|
34
34
|
}
|
|
35
35
|
const cmd = args.find(a => !a.startsWith("-")) || "start";
|
|
36
36
|
const cfgIdx = args.indexOf("--config");
|
|
37
37
|
const cfgPath = cfgIdx !== -1 ? args[cfgIdx + 1] : undefined;
|
|
38
38
|
const daemon = args.includes("--daemon") || args.includes("-d");
|
|
39
|
+
const foreground = args.includes("--foreground") || args.includes("-f");
|
|
40
|
+
const DEFAULT_CFG = join(DIR, "config.yaml");
|
|
39
41
|
switch (cmd) {
|
|
40
42
|
case "start": {
|
|
41
43
|
const existing = readPid();
|
|
@@ -43,8 +45,9 @@ switch (cmd) {
|
|
|
43
45
|
console.log(`Already running (PID ${existing})`);
|
|
44
46
|
process.exit(0);
|
|
45
47
|
}
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
+
const resolvedCfg = cfgPath || DEFAULT_CFG;
|
|
49
|
+
const childArgs = [ENTRY, "--config", resolvedCfg];
|
|
50
|
+
if (!foreground) {
|
|
48
51
|
ensureDir();
|
|
49
52
|
const { openSync } = await import("fs");
|
|
50
53
|
const logFd = openSync(LOG_FILE, "a");
|
|
@@ -96,8 +99,10 @@ switch (cmd) {
|
|
|
96
99
|
break;
|
|
97
100
|
}
|
|
98
101
|
case "init": {
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
ensureDir();
|
|
103
|
+
const target = cfgPath || DEFAULT_CFG;
|
|
104
|
+
if (existsSync(target)) {
|
|
105
|
+
console.log(`${target} already exists`);
|
|
101
106
|
process.exit(0);
|
|
102
107
|
}
|
|
103
108
|
const example = join(__dirname, "..", "config.yaml.example");
|
|
@@ -105,11 +110,11 @@ switch (cmd) {
|
|
|
105
110
|
console.error("config.yaml.example not found");
|
|
106
111
|
process.exit(1);
|
|
107
112
|
}
|
|
108
|
-
copyFileSync(example,
|
|
109
|
-
console.log(
|
|
113
|
+
copyFileSync(example, target);
|
|
114
|
+
console.log(`Created ${target} from template`);
|
|
110
115
|
break;
|
|
111
116
|
}
|
|
112
117
|
default:
|
|
113
|
-
console.log("Usage: claudebridge <start|stop|status|reload|init> [--config path] [--
|
|
118
|
+
console.log("Usage: claudebridge <start|stop|status|reload|init> [--config path] [--foreground|-f]");
|
|
114
119
|
process.exit(1);
|
|
115
120
|
}
|