@invizi/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.
Files changed (2) hide show
  1. package/dist/invizi.js +10 -3
  2. package/package.json +1 -1
package/dist/invizi.js CHANGED
@@ -20,6 +20,9 @@ Run invizi --help after login for the remote command list.
20
20
  `);
21
21
  }
22
22
  async function executeProtocol(args, authHeader) {
23
+ // Handle --json flag: output structured result instead of text
24
+ const jsonMode = args.includes('--json');
25
+ const serverArgs = args.filter(a => a !== '--json');
23
26
  const apiUrl = getApiUrl();
24
27
  const res = await fetch(`${apiUrl}/cli/v1/execute`, {
25
28
  method: 'POST',
@@ -27,7 +30,7 @@ async function executeProtocol(args, authHeader) {
27
30
  'Content-Type': 'application/json',
28
31
  Authorization: authHeader,
29
32
  },
30
- body: JSON.stringify({ argv: args }),
33
+ body: JSON.stringify({ argv: serverArgs }),
31
34
  });
32
35
  if (res.status === 404) {
33
36
  return { handled: false, exitCode: 0 };
@@ -41,10 +44,14 @@ async function executeProtocol(args, authHeader) {
41
44
  console.error('Invalid protocol response from server');
42
45
  return { handled: true, exitCode: 1 };
43
46
  }
44
- if (typeof output.text === 'string' && output.text.length > 0) {
47
+ // --json flag: output structured result instead of text
48
+ if (jsonMode && output.result !== undefined) {
49
+ process.stdout.write(`${JSON.stringify(output.result, null, 2)}\n`);
50
+ }
51
+ else if (typeof output.text === 'string' && output.text.length > 0) {
45
52
  process.stdout.write(`${output.text}${output.text.endsWith('\n') ? '' : '\n'}`);
46
53
  }
47
- if (!output.text && output.result !== undefined) {
54
+ else if (output.result !== undefined) {
48
55
  process.stdout.write(`${JSON.stringify(output.result, null, 2)}\n`);
49
56
  }
50
57
  if (output.error?.message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@invizi/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Invizi CLI",
5
5
  "type": "module",
6
6
  "bin": {