@guanlin4924/devflow-pi 0.1.4 → 0.1.5
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/package.json +1 -1
- package/src/cli.ts +10 -0
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
4
5
|
|
|
5
6
|
import { formatDoctor, runHostDoctor } from "./doctor.ts";
|
|
6
7
|
import { initializeProject, loadProjectContext, resolveProjectRoot } from "./project-context.ts";
|
|
@@ -17,6 +18,11 @@ function usage(): string {
|
|
|
17
18
|
].join("\n");
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
function packageVersion(): string {
|
|
22
|
+
const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")) as { version?: unknown };
|
|
23
|
+
return typeof packageJson.version === "string" ? packageJson.version : "unknown";
|
|
24
|
+
}
|
|
25
|
+
|
|
20
26
|
function option(args: string[], name: string): string | undefined {
|
|
21
27
|
const index = args.indexOf(name);
|
|
22
28
|
return index >= 0 ? args[index + 1] : undefined;
|
|
@@ -32,6 +38,10 @@ function optionalOption(args: string[], name: string): boolean | string | undefi
|
|
|
32
38
|
async function main(): Promise<void> {
|
|
33
39
|
const args = process.argv.slice(2);
|
|
34
40
|
const command = args[0];
|
|
41
|
+
if (command === "--version" || command === "-v" || command === "version") {
|
|
42
|
+
console.log(packageVersion());
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
35
45
|
if (command === "--help" || command === "-h" || command === "help") {
|
|
36
46
|
console.log(usage());
|
|
37
47
|
return;
|