@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.
Files changed (2) hide show
  1. package/dist/index.js +35 -26
  2. 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.6",
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("Get details for a capability from the last search").argument("<position>", "Position number from search results").action(async (positionStr) => {
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(positionStr, 10);
242
- if (Number.isNaN(position) || position < 1) {
243
- console.error("Position must be a positive integer");
244
- process.exitCode = 1;
245
- return;
246
- }
247
- const lastSearch = stateService.loadLastSearch();
248
- if (!lastSearch) {
249
- console.error("No recent search found. Run `zero search` first.");
250
- process.exitCode = 1;
251
- return;
252
- }
253
- const entry = lastSearch.capabilities.find(
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
- process.exitCode = 1;
261
- return;
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
- entry.id,
265
- lastSearch.searchId
273
+ capabilityId,
274
+ searchId
266
275
  );
267
276
  console.log(JSON.stringify(capability, null, 2));
268
277
  analyticsService.capture("capability_viewed", {
269
- capabilityId: entry.id,
270
- position
278
+ capabilityId,
279
+ ...isPosition ? { position } : {}
271
280
  });
272
281
  } catch (err) {
273
282
  console.error(err instanceof Error ? err.message : "Get failed");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeroxyz/cli",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "zero": "dist/index.js",