@flatkey-ai/cli 0.1.3 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatkey-ai/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Flatkey media generation CLI for image, video, audio, credits, status, and models.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -18,6 +18,9 @@ export function parseArgv(argv) {
18
18
  if (!group) {
19
19
  return { group: "help", action: undefined, options: {} };
20
20
  }
21
+ if (group === "--version" || group === "-v") {
22
+ return { group: "version", action: undefined, options: {} };
23
+ }
21
24
  if (!COMMANDS.has(group)) {
22
25
  throw new Error(`Unknown command: ${group}`);
23
26
  }
@@ -87,7 +90,8 @@ export async function runCommand(command, deps = {}) {
87
90
  return command.options.ai ? getAiHelp() : getHumanHelp();
88
91
  }
89
92
  if (command.group === "version") {
90
- return { version: await readPackageVersion() };
93
+ const version = await readPackageVersion();
94
+ return command.options.json ? { version } : version;
91
95
  }
92
96
 
93
97
  if (command.group === "models") {
package/test/cli.test.js CHANGED
@@ -75,6 +75,19 @@ test("parses ai help", () => {
75
75
  });
76
76
  });
77
77
 
78
+ test("parses global version aliases", () => {
79
+ assert.deepEqual(parseArgv(["--version"]), {
80
+ group: "version",
81
+ action: undefined,
82
+ options: {},
83
+ });
84
+ assert.deepEqual(parseArgv(["-v"]), {
85
+ group: "version",
86
+ action: undefined,
87
+ options: {},
88
+ });
89
+ });
90
+
78
91
  test("rejects unknown commands", () => {
79
92
  assert.throws(
80
93
  () => parseArgv(["wat"]),
@@ -85,7 +98,8 @@ test("rejects unknown commands", () => {
85
98
  test("version command matches package version", async () => {
86
99
  const pkg = JSON.parse(await (await import("node:fs/promises")).readFile("package.json", "utf8"));
87
100
 
88
- assert.deepEqual(await runCommand({ group: "version", options: {} }), {
101
+ assert.equal(await runCommand({ group: "version", options: {} }), pkg.version);
102
+ assert.deepEqual(await runCommand({ group: "version", options: { json: true } }), {
89
103
  version: pkg.version,
90
104
  });
91
105
  });