nansen-cli 1.0.1 → 1.0.2

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/package.json +1 -1
  2. package/src/index.js +21 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nansen-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Command-line interface for Nansen API - designed for AI agents",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -156,6 +156,22 @@ function errorOutput(error, pretty = false, table = false) {
156
156
  process.exit(1);
157
157
  }
158
158
 
159
+ // Parse simple sort syntax: "field:direction" or "field" (defaults to DESC)
160
+ function parseSort(sortOption, orderByOption) {
161
+ // If --order-by is provided, use it (full JSON control)
162
+ if (orderByOption) return orderByOption;
163
+
164
+ // If no --sort, return undefined
165
+ if (!sortOption) return undefined;
166
+
167
+ // Parse --sort field:direction or --sort field
168
+ const parts = sortOption.split(':');
169
+ const field = parts[0];
170
+ const direction = (parts[1] || 'desc').toUpperCase();
171
+
172
+ return [{ field, direction }];
173
+ }
174
+
159
175
  // Help text
160
176
  const HELP = `
161
177
  Nansen CLI - Command-line interface for Nansen API
@@ -180,7 +196,8 @@ GLOBAL OPTIONS:
180
196
  --chains Multiple chains as JSON array
181
197
  --limit Number of results (shorthand for pagination)
182
198
  --filters JSON object with filters
183
- --order-by JSON array with sort order
199
+ --sort Sort by field (e.g., --sort value_usd:desc)
200
+ --order-by JSON array with sort order (advanced)
184
201
  --days Date range in days (default: 30 for most endpoints)
185
202
  --symbol Token symbol (for perp endpoints)
186
203
 
@@ -316,7 +333,7 @@ const commands = {
316
333
  const chain = options.chain || 'solana';
317
334
  const chains = options.chains || [chain];
318
335
  const filters = options.filters || {};
319
- const orderBy = options['order-by'];
336
+ const orderBy = parseSort(options.sort, options['order-by']);
320
337
  const pagination = options.limit ? { page: 1, per_page: options.limit } : undefined;
321
338
 
322
339
  // Add smart money label filter if specified
@@ -355,7 +372,7 @@ const commands = {
355
372
  const entityName = options.entity || options['entity-name'];
356
373
  const chain = options.chain || 'ethereum';
357
374
  const filters = options.filters || {};
358
- const orderBy = options['order-by'];
375
+ const orderBy = parseSort(options.sort, options['order-by']);
359
376
  const pagination = options.limit ? { page: 1, recordsPerPage: options.limit } : undefined;
360
377
  const days = options.days ? parseInt(options.days) : 30;
361
378
 
@@ -393,7 +410,7 @@ const commands = {
393
410
  const chains = options.chains || [chain];
394
411
  const timeframe = options.timeframe || '24h';
395
412
  const filters = options.filters || {};
396
- const orderBy = options['order-by'];
413
+ const orderBy = parseSort(options.sort, options['order-by']);
397
414
  const pagination = options.limit ? { page: 1, per_page: options.limit } : undefined;
398
415
  const days = options.days ? parseInt(options.days) : 30;
399
416