@zeroxyz/cli 0.0.6 → 0.0.7
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/index.js +35 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command as Command8 } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@zeroxyz/cli",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.7",
|
|
10
10
|
type: "module",
|
|
11
11
|
bin: {
|
|
12
12
|
zero: "dist/index.js",
|
|
@@ -235,39 +235,48 @@ var fetchCommand = (appContext2) => new Command2("fetch").description("Fetch a c
|
|
|
235
235
|
|
|
236
236
|
// src/commands/get-command.ts
|
|
237
237
|
import { Command as Command3 } from "commander";
|
|
238
|
-
var getCommand = (appContext2) => new Command3("get").description(
|
|
238
|
+
var getCommand = (appContext2) => new Command3("get").description(
|
|
239
|
+
"Get details for a capability by position from last search, or by slug"
|
|
240
|
+
).argument(
|
|
241
|
+
"<identifier>",
|
|
242
|
+
"Position number from search results, or a capability slug"
|
|
243
|
+
).action(async (identifier) => {
|
|
239
244
|
try {
|
|
240
245
|
const { analyticsService, apiService, stateService } = appContext2.services;
|
|
241
|
-
const position = Number.parseInt(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
(c) => c.position === position
|
|
255
|
-
);
|
|
256
|
-
if (!entry) {
|
|
257
|
-
console.error(
|
|
258
|
-
`No capability at position ${position}. Positions: ${lastSearch.capabilities.map((c) => c.position).join(", ")}`
|
|
246
|
+
const position = Number.parseInt(identifier, 10);
|
|
247
|
+
const isPosition = !Number.isNaN(position) && position >= 1;
|
|
248
|
+
let capabilityId;
|
|
249
|
+
let searchId;
|
|
250
|
+
if (isPosition) {
|
|
251
|
+
const lastSearch = stateService.loadLastSearch();
|
|
252
|
+
if (!lastSearch) {
|
|
253
|
+
console.error("No recent search found. Run `zero search` first.");
|
|
254
|
+
process.exitCode = 1;
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const entry = lastSearch.capabilities.find(
|
|
258
|
+
(c) => c.position === position
|
|
259
259
|
);
|
|
260
|
-
|
|
261
|
-
|
|
260
|
+
if (!entry) {
|
|
261
|
+
console.error(
|
|
262
|
+
`No capability at position ${position}. Positions: ${lastSearch.capabilities.map((c) => c.position).join(", ")}`
|
|
263
|
+
);
|
|
264
|
+
process.exitCode = 1;
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
capabilityId = entry.id;
|
|
268
|
+
searchId = lastSearch.searchId;
|
|
269
|
+
} else {
|
|
270
|
+
capabilityId = identifier;
|
|
262
271
|
}
|
|
263
272
|
const capability = await apiService.getCapability(
|
|
264
|
-
|
|
265
|
-
|
|
273
|
+
capabilityId,
|
|
274
|
+
searchId
|
|
266
275
|
);
|
|
267
276
|
console.log(JSON.stringify(capability, null, 2));
|
|
268
277
|
analyticsService.capture("capability_viewed", {
|
|
269
|
-
capabilityId
|
|
270
|
-
position
|
|
278
|
+
capabilityId,
|
|
279
|
+
...isPosition ? { position } : {}
|
|
271
280
|
});
|
|
272
281
|
} catch (err) {
|
|
273
282
|
console.error(err instanceof Error ? err.message : "Get failed");
|