@ascdong/nexus 0.1.2 → 0.1.3

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 (3) hide show
  1. package/README.md +2 -2
  2. package/dist/cli.js +16 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -140,10 +140,10 @@ The `envelope` form declares column names once (instead of repeating them on eve
140
140
 
141
141
  ## Output channels & exit codes
142
142
 
143
- - **Results** go to **stdout**; **logs and errors** go to **stderr** — so an Agent can parse stdout cleanly.
143
+ - **Results** go to **stdout**; **diagnostic logs** go to **stderr** — so an Agent can parse stdout cleanly.
144
144
  - Exit codes: `0` success, `1` query/connection/auth error, `2` usage/config error.
145
145
 
146
- On error, `json`/`envelope` output a structured `{ "status": "error", "code": "...", "message": "..." }`.
146
+ On error, `json`/`envelope` mode writes a structured `{ "status": "error", "code": "...", "message": "..." }` to **stdout** (so the single stream stays self-describing — `status` is `"ok"` or `"error"`), while the default `table` mode prints `error [CODE]: message` to **stderr**. Either way the exit code is non-zero.
147
147
 
148
148
  ## Extending
149
149
 
package/dist/cli.js CHANGED
@@ -4,6 +4,7 @@ import { pathToFileURL } from "node:url";
4
4
  import { Command } from "commander";
5
5
  import { register } from "./core/registry.js";
6
6
  import { ConnectorError, exitCodeFor } from "./core/errors.js";
7
+ import { renderError } from "./core/output.js";
7
8
  import { makeLogAnalyticsConnector } from "./connectors/logAnalytics.js";
8
9
  import { makeKustoConnector } from "./connectors/kusto.js";
9
10
  import { makeAzureSqlConnector } from "./connectors/azureSql.js";
@@ -19,7 +20,7 @@ export function registerConnectors() {
19
20
  }
20
21
  export function buildProgram() {
21
22
  const program = new Command();
22
- program.name("nexus").description("Unified Azure data access CLI").version("0.1.2");
23
+ program.name("nexus").description("Unified Azure data access CLI").version("0.1.3");
23
24
  registerConnectorCommand(program);
24
25
  registerQueryCommand(program);
25
26
  registerSchemaCommand(program);
@@ -27,6 +28,11 @@ export function buildProgram() {
27
28
  registerStorageAccountCommand(program);
28
29
  return program;
29
30
  }
31
+ export function requestedFormat(argv) {
32
+ const i = argv.indexOf("--output");
33
+ const v = i >= 0 ? argv[i + 1] : undefined;
34
+ return v === "json" || v === "envelope" ? v : "table";
35
+ }
30
36
  async function main() {
31
37
  registerConnectors();
32
38
  const program = buildProgram();
@@ -35,7 +41,15 @@ async function main() {
35
41
  }
36
42
  catch (e) {
37
43
  if (e instanceof ConnectorError) {
38
- process.stderr.write(`error [${e.code}]: ${e.message}\n`);
44
+ const format = requestedFormat(process.argv);
45
+ if (format === "table") {
46
+ process.stderr.write(renderError(e.code, e.message, format) + "\n");
47
+ }
48
+ else {
49
+ // json/envelope: emit a self-describing { status: "error", ... } on stdout
50
+ // so an agent parsing a single stream can branch on `status`.
51
+ process.stdout.write(renderError(e.code, e.message, format) + "\n");
52
+ }
39
53
  process.exit(exitCodeFor(e.code));
40
54
  }
41
55
  process.stderr.write(`error: ${e.message}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ascdong/nexus",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Unified Azure data access CLI for Log Analytics, Kusto, Azure SQL, and Storage Account",
5
5
  "type": "module",
6
6
  "bin": {