@atlaskit/ads-cli 0.5.0 → 0.6.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @atlaskit/ads-cli
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`23b45bcd71b5d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/23b45bcd71b5d) -
8
+ Add an in-process batch command for running multiple ADS CLI queries with independent results,
9
+ using a repeated `--command` flag to introduce each child request.
10
+
11
+ For example:
12
+
13
+ ```sh
14
+ npx @atlaskit/ads-cli batch --command search button --type icon --command token space.200
15
+ ```
16
+
17
+ For readability, put each `--command` group on its own line — the two forms are equivalent:
18
+
19
+ ```sh
20
+ npx @atlaskit/ads-cli batch \
21
+ --command search button --type icon \
22
+ --command token space.200
23
+ ```
24
+
3
25
  ## 0.5.0
4
26
 
5
27
  ### Minor Changes
package/README.md CHANGED
@@ -21,15 +21,16 @@ default; `--json` emits a stable, self-describing envelope for machine consumers
21
21
 
22
22
  The CLI has these commands:
23
23
 
24
- | Command | Description |
25
- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
26
- | `search <query...>` | **Unified** fuzzy-search across components, tokens, icons, and foundations docs at once. Narrow results with `--type component\|token\|icon\|docs`; limit with `--limit N`. |
27
- | `component <name>` | Detail for a single component. Exact name → detail; ambiguous → a "did you mean?" list. `--all` lists every component. |
28
- | `token <name>` | Detail for a single token. Exact name → detail; ambiguous → a "did you mean?" list. `--all` lists every token. |
29
- | `icon <name>` | Detail for a single icon (with a copy-paste import). Exact name → detail; ambiguous → a "did you mean?" list. `--all` lists every icon. |
30
- | `lint-rules [term...]` | ADS ESLint rules. A term that matches one rule (exactly or uniquely) prints its docs; several matches show a "did you mean?" list. Bare `lint-rules` prints every rule; `--limit N` caps the candidate list. |
31
- | `docs <topic...>` | Read ADS reference docs. Three forms:<br>• `docs <term...>` — foundations guidelines (spacing, color, …)<br>• `docs a11y [topic]` — accessibility guidance (optional topic e.g. `buttons`, `forms`, `colors`)<br>• `docs migration <id>` — a structured migration guide |
32
- | `manifest` | Describe every command, argument, flag, and JSON response type. Use `--json` for the machine-readable contract. |
24
+ | Command | Description |
25
+ | ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
26
+ | `search <query...>` | **Unified** fuzzy-search across components, tokens, icons, and foundations docs at once. Narrow results with `--type component\|token\|icon\|docs`; limit with `--limit N`. |
27
+ | `batch --command <command> [args...]...` | Run multiple ADS CLI queries, including different command types, in one process. Repeat `--command` once per child; each keeps its normal arguments, flags, and response envelope. |
28
+ | `component <name>` | Detail for a single component. Exact name → detail; ambiguous → a "did you mean?" list. `--all` lists every component. |
29
+ | `token <name>` | Detail for a single token. Exact name → detail; ambiguous → a "did you mean?" list. `--all` lists every token. |
30
+ | `icon <name>` | Detail for a single icon (with a copy-paste import). Exact name → detail; ambiguous → a "did you mean?" list. `--all` lists every icon. |
31
+ | `lint-rules [term...]` | ADS ESLint rules. A term that matches one rule (exactly or uniquely) prints its docs; several matches show a "did you mean?" list. Bare `lint-rules` prints every rule; `--limit N` caps the candidate list. |
32
+ | `docs <topic...>` | Read ADS reference docs. Three forms:<br>• `docs <term...>` — foundations guidelines (spacing, color, …)<br>• `docs a11y [topic]` — accessibility guidance (optional topic e.g. `buttons`, `forms`, `colors`)<br>• `docs migration <id>` — a structured migration guide |
33
+ | `manifest` | Describe every command, argument, flag, and JSON response type. Use `--json` for the machine-readable contract. |
33
34
 
34
35
  ### Global flags
35
36
 
@@ -47,6 +48,13 @@ npx @atlaskit/ads-cli search contrast
47
48
  npx @atlaskit/ads-cli search space color --type token
48
49
  npx @atlaskit/ads-cli search contrast --type docs
49
50
 
51
+ # Run multiple queries, including different command types, in one process
52
+ npx @atlaskit/ads-cli batch \
53
+ --command component Button \
54
+ --command component Modal \
55
+ --command docs spacing \
56
+ --command search contrast --type docs
57
+
50
58
  # Detail for a single component, token, or icon
51
59
  npx @atlaskit/ads-cli component Avatar
52
60
  npx @atlaskit/ads-cli token space.100
@@ -84,8 +92,16 @@ npx @atlaskit/ads-cli manifest --json
84
92
  is no exact match but several candidates, they print a `Did you mean?` list (each with a
85
93
  `→ ads-cli <command>` follow-up) and exit `0` — under `--json` this is
86
94
  `{ "ambiguous": true, "query", "noun", "candidates": [...] }`.
95
+ - **Batch commands are independent.** Each repeated `--command` starts a tokenized child request;
96
+ `batch` runs those commands concurrently through the existing command registry in one CLI process.
97
+ Each item includes its original tokenized `request`, a `status` (`success`, `ambiguous`, or
98
+ `failure`), and the child command's unchanged success or error `response` envelope. A failed or
99
+ ambiguous child does not discard successful sibling results. A syntactically valid batch exits
100
+ `0`; inspect each item's status or nested envelope.
87
101
  - **Data is written to stdout only.** Logs, hints, and errors go to **stderr**. This keeps `--json`
88
- output clean for piping.
102
+ output clean for piping. `batch` is the one deliberate exception: a child's failure is part of the
103
+ aggregate result rather than a failure of the batch itself, so per-child errors stay inline on
104
+ stdout beside their `Request:` heading instead of being split onto stderr.
89
105
  - **The manifest is derived from the live command registry.** `manifest --json` lists every command,
90
106
  positional argument, flag, example, and success response type without maintaining a separate copy
91
107
  of the CLI surface.
@@ -122,6 +138,42 @@ npx @atlaskit/ads-cli manifest --json
122
138
  "meta": { "terms": ["avatar"], "limit": 5, "count": 2 }
123
139
  }
124
140
 
141
+ // success — batch preserves each child command's existing envelope
142
+ {
143
+ "type": "ads-cli/batch",
144
+ "command": "batch",
145
+ "ok": true,
146
+ "data": [
147
+ {
148
+ "request": ["component", "Button"],
149
+ "status": "success",
150
+ "response": {
151
+ "type": "ads-cli/component",
152
+ "command": "component",
153
+ "ok": true,
154
+ "data": { /* full Button data */ },
155
+ "meta": { "name": "Button" }
156
+ }
157
+ },
158
+ {
159
+ "request": ["docs", "missing-topic"],
160
+ "status": "failure",
161
+ "response": {
162
+ "type": "ads-cli/error",
163
+ "command": "docs",
164
+ "ok": false,
165
+ "error": { "code": "NOT_FOUND", "message": "No guidelines found for missing-topic." }
166
+ }
167
+ }
168
+ ],
169
+ "meta": {
170
+ "succeeded": 1,
171
+ "ambiguous": 0,
172
+ "failed": 1,
173
+ "count": 2
174
+ }
175
+ }
176
+
125
177
  // failure
126
178
  {
127
179
  "type": "ads-cli/error",
package/dist/cjs/cli.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.run = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
12
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
@@ -18,7 +19,9 @@ var _runTool = require("./commands/run-tool");
18
19
  var _createErrorEnvelope = require("./envelope/create-error-envelope");
19
20
  var _createSuccessEnvelope = require("./envelope/create-success-envelope");
20
21
  var _createDocSearchResults = require("./output/create-doc-search-results");
22
+ var _disambiguation = require("./output/disambiguation");
21
23
  var _formatGroupedResults = require("./output/format-grouped-results");
24
+ var _formatHumanResult = require("./output/format-human-result");
22
25
  var _formatResults = require("./output/format-results");
23
26
  var _writeHumanError = require("./output/write-human-error");
24
27
  var _writeHumanResult = require("./output/write-human-result");
@@ -67,6 +70,9 @@ var buildHelpText = function buildHelpText(invocation) {
67
70
  var examples = [{
68
71
  command: 'search contrast',
69
72
  comment: 'unified: components, tokens, icons & docs'
73
+ }, {
74
+ command: 'batch --command search button --type icon --command token space.200',
75
+ comment: 'independent commands in one process'
70
76
  }, {
71
77
  command: 'search button --type component'
72
78
  }, {
@@ -159,7 +165,19 @@ var runRegistryCommand = /*#__PURE__*/function () {
159
165
  invocation: invocation
160
166
  }));
161
167
  case 2:
162
- _context2.next = 3;
168
+ if (!resolved.batch) {
169
+ _context2.next = 3;
170
+ break;
171
+ }
172
+ return _context2.abrupt("return", runBatchRequests({
173
+ command: command,
174
+ requests: resolved.batch,
175
+ json: json,
176
+ writer: writer,
177
+ invocation: invocation
178
+ }));
179
+ case 3:
180
+ _context2.next = 4;
163
181
  return Promise.all(resolved.tools.map( /*#__PURE__*/function () {
164
182
  var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(tool) {
165
183
  var handler, _t, _t2;
@@ -194,10 +212,10 @@ var runRegistryCommand = /*#__PURE__*/function () {
194
212
  return _ref5.apply(this, arguments);
195
213
  };
196
214
  }()));
197
- case 3:
215
+ case 4:
198
216
  results = _context2.sent;
199
217
  if (!resolved.grouped) {
200
- _context2.next = 4;
218
+ _context2.next = 5;
201
219
  break;
202
220
  }
203
221
  return _context2.abrupt("return", renderGroupedResult({
@@ -209,7 +227,7 @@ var runRegistryCommand = /*#__PURE__*/function () {
209
227
  writer: writer,
210
228
  invocation: invocation
211
229
  }));
212
- case 4:
230
+ case 5:
213
231
  return _context2.abrupt("return", renderSingleResult({
214
232
  command: command,
215
233
  input: input,
@@ -219,7 +237,7 @@ var runRegistryCommand = /*#__PURE__*/function () {
219
237
  writer: writer,
220
238
  invocation: invocation
221
239
  }));
222
- case 5:
240
+ case 6:
223
241
  case "end":
224
242
  return _context2.stop();
225
243
  }
@@ -231,17 +249,45 @@ var runRegistryCommand = /*#__PURE__*/function () {
231
249
  }();
232
250
 
233
251
  /**
234
- * Render a single-tool command result (the common case).
252
+ * Render a command's already-transformed payload as human-readable text.
253
+ *
254
+ * Tried in order:
255
+ * 1. Compact per-row view when the command declares a result kind (search/list).
256
+ * 2. The command's own `formatHuman` renderer for rich single-object payloads
257
+ * (component docs, a11y/migration guides, lint-rule markdown).
258
+ *
259
+ * Returns `null` when neither step applies, leaving the caller to choose its own last-resort
260
+ * fallback. Shared by the single-command path and `batch` so the two cannot drift apart.
235
261
  */
236
- var renderSingleResult = function renderSingleResult(_ref6) {
262
+ var formatCommandHuman = function formatCommandHuman(_ref6) {
237
263
  var _command$resultKind, _ref7, _command$formatHuman;
238
264
  var command = _ref6.command,
239
265
  input = _ref6.input,
240
- result = _ref6.result,
241
- meta = _ref6.meta,
242
- json = _ref6.json,
243
- writer = _ref6.writer,
266
+ data = _ref6.data,
244
267
  invocation = _ref6.invocation;
268
+ var resultKind = (_command$resultKind = command.resultKind) === null || _command$resultKind === void 0 ? void 0 : _command$resultKind.call(command, input);
269
+ var compact = resultKind ? (0, _formatResults.formatCompactResults)({
270
+ kind: resultKind,
271
+ data: data,
272
+ showFollowUp: command.name === 'search',
273
+ invocation: invocation
274
+ }) : null;
275
+ return (_ref7 = compact !== null && compact !== void 0 ? compact : (_command$formatHuman = command.formatHuman) === null || _command$formatHuman === void 0 ? void 0 : _command$formatHuman.call(command, data, {
276
+ invocation: invocation
277
+ })) !== null && _ref7 !== void 0 ? _ref7 : null;
278
+ };
279
+
280
+ /**
281
+ * Render a single-tool command result (the common case).
282
+ */
283
+ var renderSingleResult = function renderSingleResult(_ref8) {
284
+ var command = _ref8.command,
285
+ input = _ref8.input,
286
+ result = _ref8.result,
287
+ meta = _ref8.meta,
288
+ json = _ref8.json,
289
+ writer = _ref8.writer,
290
+ invocation = _ref8.invocation;
245
291
  var isError = result.isError;
246
292
 
247
293
  // The ADS search tools return an `Error: No … found` text block when nothing matches.
@@ -307,22 +353,14 @@ var renderSingleResult = function renderSingleResult(_ref6) {
307
353
  return _types.ExitCode.Ok;
308
354
  }
309
355
 
310
- // Default (human) output, tried in order:
311
- // 1. Compact per-row view when the command declares a result kind (search/list).
312
- // 2. The command's own `formatHuman` renderer for rich single-object payloads
313
- // (component docs, a11y/migration guides, lint-rule markdown).
314
- // 3. The generic fallback: verbatim strings (e.g. foundations markdown) or pretty JSON.
315
- // Each step returns `null` to defer to the next, so a raw JSON dump is only ever a last resort.
316
- var resultKind = (_command$resultKind = command.resultKind) === null || _command$resultKind === void 0 ? void 0 : _command$resultKind.call(command, input);
317
- var compact = resultKind ? (0, _formatResults.formatCompactResults)({
318
- kind: resultKind,
356
+ // Default (human) output: the shared renderer, falling back to verbatim strings (e.g.
357
+ // foundations markdown) or pretty JSON so a raw dump is only ever a last resort.
358
+ var human = formatCommandHuman({
359
+ command: command,
360
+ input: input,
319
361
  data: data,
320
- showFollowUp: command.name === 'search',
321
- invocation: invocation
322
- }) : null;
323
- var human = (_ref7 = compact !== null && compact !== void 0 ? compact : (_command$formatHuman = command.formatHuman) === null || _command$formatHuman === void 0 ? void 0 : _command$formatHuman.call(command, data, {
324
362
  invocation: invocation
325
- })) !== null && _ref7 !== void 0 ? _ref7 : null;
363
+ });
326
364
  if (human !== null) {
327
365
  writer.out(human);
328
366
  } else {
@@ -333,6 +371,209 @@ var renderSingleResult = function renderSingleResult(_ref6) {
333
371
  }
334
372
  return _types.ExitCode.Ok;
335
373
  };
374
+ var classifyBatchResponse = function classifyBatchResponse(response) {
375
+ if (!response.ok) {
376
+ return 'failure';
377
+ }
378
+ return (0, _disambiguation.isDisambiguation)(response.data) ? 'ambiguous' : 'success';
379
+ };
380
+ var createCapturedWriter = function createCapturedWriter() {
381
+ var stdout = [];
382
+ var stderr = [];
383
+ return {
384
+ stdout: stdout,
385
+ stderr: stderr,
386
+ out: function out(line) {
387
+ return stdout.push(line);
388
+ },
389
+ err: function err(line) {
390
+ return stderr.push(line);
391
+ }
392
+ };
393
+ };
394
+
395
+ /**
396
+ * Execute one child argv through the normal CLI pipeline, forcing JSON so the parent can preserve
397
+ * the child's stable envelope without scraping human-readable output.
398
+ *
399
+ * There is deliberately no `--help`/`--version` guard here. Every child token is also a top-level
400
+ * token, so {@link run} already short-circuits the whole invocation to help/version text before a
401
+ * batch is ever resolved — a guard at this level would be unreachable.
402
+ */
403
+ var runBatchChild = /*#__PURE__*/function () {
404
+ var _ref0 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref9) {
405
+ var request, invocation, parsed, response, captured;
406
+ return _regenerator.default.wrap(function (_context3) {
407
+ while (1) switch (_context3.prev = _context3.next) {
408
+ case 0:
409
+ request = _ref9.request, invocation = _ref9.invocation;
410
+ parsed = (0, _parseArgs2.parseArgs)(request.argv);
411
+ if (parsed.command) {
412
+ _context3.next = 1;
413
+ break;
414
+ }
415
+ response = (0, _createErrorEnvelope.createErrorEnvelope)({
416
+ command: 'batch',
417
+ code: 'USAGE_ERROR',
418
+ message: 'A batch request must start with a command name.'
419
+ });
420
+ _context3.next = 4;
421
+ break;
422
+ case 1:
423
+ if (!(parsed.command === 'batch')) {
424
+ _context3.next = 2;
425
+ break;
426
+ }
427
+ response = (0, _createErrorEnvelope.createErrorEnvelope)({
428
+ command: 'batch',
429
+ code: 'USAGE_ERROR',
430
+ message: 'Nested batch requests are not supported.'
431
+ });
432
+ _context3.next = 4;
433
+ break;
434
+ case 2:
435
+ captured = createCapturedWriter();
436
+ _context3.next = 3;
437
+ return run([].concat((0, _toConsumableArray2.default)(request.argv), ['--json']), captured, {
438
+ invocation: invocation
439
+ });
440
+ case 3:
441
+ try {
442
+ response = JSON.parse(captured.stdout.join('\n'));
443
+ } catch (_unused) {
444
+ response = (0, _createErrorEnvelope.createErrorEnvelope)({
445
+ command: parsed.command,
446
+ code: 'RUNTIME_ERROR',
447
+ message: 'The child command did not produce a valid JSON envelope.'
448
+ });
449
+ }
450
+ case 4:
451
+ return _context3.abrupt("return", {
452
+ request: request.argv,
453
+ status: classifyBatchResponse(response),
454
+ response: response
455
+ });
456
+ case 5:
457
+ case "end":
458
+ return _context3.stop();
459
+ }
460
+ }, _callee3);
461
+ }));
462
+ return function runBatchChild(_x3) {
463
+ return _ref0.apply(this, arguments);
464
+ };
465
+ }();
466
+
467
+ /**
468
+ * Render an already-transformed child success envelope with the same human format as its command.
469
+ */
470
+ var formatBatchChildHuman = function formatBatchChildHuman(_ref1) {
471
+ var item = _ref1.item,
472
+ invocation = _ref1.invocation;
473
+ if (!item.response.ok) {
474
+ return "Error: ".concat(item.response.error.message);
475
+ }
476
+ var parsed = (0, _parseArgs2.parseArgs)(item.request);
477
+ var definition = parsed.command ? (0, _getCommand.getCommand)(parsed.command) : undefined;
478
+ if (!definition) {
479
+ return (0, _formatHumanResult.formatHumanResult)({
480
+ data: item.response.data
481
+ });
482
+ }
483
+
484
+ // A unified search spans every kind, so it has no single result kind and needs the grouped
485
+ // formatter instead. This is the same condition `search`'s own resolver uses to choose the
486
+ // grouped path, so the two cannot disagree.
487
+ if (definition.name === 'search' && parsed.flags.type === undefined && (0, _typeof2.default)(item.response.data) === 'object' && item.response.data !== null) {
488
+ var _item$response$meta$c;
489
+ return (0, _formatGroupedResults.formatGroupedResults)({
490
+ groups: item.response.data,
491
+ totalCount: Number((_item$response$meta$c = item.response.meta.count) !== null && _item$response$meta$c !== void 0 ? _item$response$meta$c : 0),
492
+ invocation: invocation
493
+ });
494
+ }
495
+ var human = formatCommandHuman({
496
+ command: definition,
497
+ input: {
498
+ positionals: parsed.positionals,
499
+ flags: parsed.flags
500
+ },
501
+ data: item.response.data,
502
+ invocation: invocation
503
+ });
504
+ return human !== null && human !== void 0 ? human : (0, _formatHumanResult.formatHumanResult)({
505
+ data: item.response.data
506
+ });
507
+ };
508
+
509
+ /**
510
+ * Execute heterogeneous registered commands concurrently in the current process and aggregate
511
+ * their existing envelopes. A valid batch exits zero even when individual child commands fail.
512
+ */
513
+ var runBatchRequests = /*#__PURE__*/function () {
514
+ var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(_ref10) {
515
+ var command, requests, json, writer, invocation, items, succeeded, ambiguous, failed, summary, sections;
516
+ return _regenerator.default.wrap(function (_context4) {
517
+ while (1) switch (_context4.prev = _context4.next) {
518
+ case 0:
519
+ command = _ref10.command, requests = _ref10.requests, json = _ref10.json, writer = _ref10.writer, invocation = _ref10.invocation;
520
+ _context4.next = 1;
521
+ return Promise.all(requests.map(function (request) {
522
+ return runBatchChild({
523
+ request: request,
524
+ invocation: invocation
525
+ });
526
+ }));
527
+ case 1:
528
+ items = _context4.sent;
529
+ succeeded = items.filter(function (item) {
530
+ return item.status === 'success';
531
+ }).length;
532
+ ambiguous = items.filter(function (item) {
533
+ return item.status === 'ambiguous';
534
+ }).length;
535
+ failed = items.length - succeeded - ambiguous;
536
+ if (!json) {
537
+ _context4.next = 2;
538
+ break;
539
+ }
540
+ (0, _writeJsonEnvelope.writeJsonEnvelope)({
541
+ envelope: (0, _createSuccessEnvelope.createSuccessEnvelope)({
542
+ envelopeType: command.envelopeType({
543
+ positionals: [],
544
+ flags: {}
545
+ }),
546
+ command: command.name,
547
+ data: items,
548
+ meta: {
549
+ succeeded: succeeded,
550
+ ambiguous: ambiguous,
551
+ failed: failed
552
+ }
553
+ }),
554
+ writer: writer
555
+ });
556
+ return _context4.abrupt("return", _types.ExitCode.Ok);
557
+ case 2:
558
+ summary = "Batch results: ".concat(succeeded, " succeeded, ").concat(ambiguous, " ambiguous, ").concat(failed, " failed");
559
+ sections = items.map(function (item) {
560
+ return "Request: ".concat(item.request.join(' '), "\n").concat(formatBatchChildHuman({
561
+ item: item,
562
+ invocation: invocation
563
+ }));
564
+ });
565
+ writer.out([summary].concat((0, _toConsumableArray2.default)(sections)).join('\n\n'));
566
+ return _context4.abrupt("return", _types.ExitCode.Ok);
567
+ case 3:
568
+ case "end":
569
+ return _context4.stop();
570
+ }
571
+ }, _callee4);
572
+ }));
573
+ return function runBatchRequests(_x4) {
574
+ return _ref11.apply(this, arguments);
575
+ };
576
+ }();
336
577
 
337
578
  /**
338
579
  * Render a grouped (multi-tool) command result, e.g. unified `search`.
@@ -340,14 +581,14 @@ var renderSingleResult = function renderSingleResult(_ref6) {
340
581
  * Each sub-result is keyed by its {@link ToolCall.key}. A sub-search that finds nothing simply
341
582
  * contributes an empty array; the command is only treated as NOT_FOUND when every group is empty.
342
583
  */
343
- var renderGroupedResult = function renderGroupedResult(_ref8) {
344
- var command = _ref8.command,
345
- input = _ref8.input,
346
- results = _ref8.results,
347
- meta = _ref8.meta,
348
- json = _ref8.json,
349
- writer = _ref8.writer,
350
- invocation = _ref8.invocation;
584
+ var renderGroupedResult = function renderGroupedResult(_ref12) {
585
+ var command = _ref12.command,
586
+ input = _ref12.input,
587
+ results = _ref12.results,
588
+ meta = _ref12.meta,
589
+ json = _ref12.json,
590
+ writer = _ref12.writer,
591
+ invocation = _ref12.invocation;
351
592
  // Assemble `{ [key]: results }`, coercing "no matches" sub-results to empty arrays so one
352
593
  // empty domain does not blank out the others. The guidelines tool returns full Markdown, so
353
594
  // summarize its highest-ranked match for search; `docs <query>` remains the detail view.
@@ -428,11 +669,11 @@ var renderGroupedResult = function renderGroupedResult(_ref8) {
428
669
  * @returns The process exit code. The bin wrapper maps this onto `process.exit`.
429
670
  */
430
671
  var run = exports.run = /*#__PURE__*/function () {
431
- var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
672
+ var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
432
673
  var argv,
433
674
  writer,
434
- _ref0,
435
- _ref0$invocation,
675
+ _ref14,
676
+ _ref14$invocation,
436
677
  invocation,
437
678
  _parseArgs,
438
679
  command,
@@ -442,33 +683,33 @@ var run = exports.run = /*#__PURE__*/function () {
442
683
  definition,
443
684
  message,
444
685
  _message2,
445
- _args3 = arguments,
686
+ _args5 = arguments,
446
687
  _t3;
447
- return _regenerator.default.wrap(function (_context3) {
448
- while (1) switch (_context3.prev = _context3.next) {
688
+ return _regenerator.default.wrap(function (_context5) {
689
+ while (1) switch (_context5.prev = _context5.next) {
449
690
  case 0:
450
- argv = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : process.argv.slice(2);
451
- writer = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : _writer.defaultWriter;
452
- _ref0 = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {}, _ref0$invocation = _ref0.invocation, invocation = _ref0$invocation === void 0 ? _cliMetadata.CLI_BIN_NAME : _ref0$invocation;
691
+ argv = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : process.argv.slice(2);
692
+ writer = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : _writer.defaultWriter;
693
+ _ref14 = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {}, _ref14$invocation = _ref14.invocation, invocation = _ref14$invocation === void 0 ? _cliMetadata.CLI_BIN_NAME : _ref14$invocation;
453
694
  _parseArgs = (0, _parseArgs2.parseArgs)(argv), command = _parseArgs.command, positionals = _parseArgs.positionals, flags = _parseArgs.flags;
454
695
  json = flags.json === true; // `--version` / `-v` takes precedence and short-circuits.
455
696
  if (!(flags.version === true)) {
456
- _context3.next = 1;
697
+ _context5.next = 1;
457
698
  break;
458
699
  }
459
700
  writer.out((0, _getVersion.getVersion)());
460
- return _context3.abrupt("return", _types.ExitCode.Ok);
701
+ return _context5.abrupt("return", _types.ExitCode.Ok);
461
702
  case 1:
462
703
  if (!(flags.help === true || command === undefined)) {
463
- _context3.next = 2;
704
+ _context5.next = 2;
464
705
  break;
465
706
  }
466
707
  writer.out(buildHelpText(invocation));
467
- return _context3.abrupt("return", command === undefined && flags.help !== true ? _types.ExitCode.UsageError : _types.ExitCode.Ok);
708
+ return _context5.abrupt("return", command === undefined && flags.help !== true ? _types.ExitCode.UsageError : _types.ExitCode.Ok);
468
709
  case 2:
469
710
  definition = (0, _getCommand.getCommand)(command);
470
711
  if (definition) {
471
- _context3.next = 3;
712
+ _context5.next = 3;
472
713
  break;
473
714
  }
474
715
  message = "Unknown command \"".concat(command, "\".");
@@ -488,25 +729,26 @@ var run = exports.run = /*#__PURE__*/function () {
488
729
  });
489
730
  writer.err("Run `".concat(invocation, " --help` to see available commands."));
490
731
  }
491
- return _context3.abrupt("return", _types.ExitCode.UsageError);
732
+ return _context5.abrupt("return", _types.ExitCode.UsageError);
492
733
  case 3:
493
- _context3.prev = 3;
494
- _context3.next = 4;
734
+ _context5.prev = 3;
735
+ _context5.next = 4;
495
736
  return runRegistryCommand({
496
737
  command: definition,
497
738
  input: {
498
739
  positionals: positionals,
499
- flags: flags
740
+ flags: flags,
741
+ rawArgs: argv
500
742
  },
501
743
  json: json,
502
744
  writer: writer,
503
745
  invocation: invocation
504
746
  });
505
747
  case 4:
506
- return _context3.abrupt("return", _context3.sent);
748
+ return _context5.abrupt("return", _context5.sent);
507
749
  case 5:
508
- _context3.prev = 5;
509
- _t3 = _context3["catch"](3);
750
+ _context5.prev = 5;
751
+ _t3 = _context5["catch"](3);
510
752
  _message2 = _t3 instanceof Error ? _t3.message : String(_t3);
511
753
  if (json) {
512
754
  (0, _writeJsonEnvelope.writeJsonEnvelope)({
@@ -523,14 +765,14 @@ var run = exports.run = /*#__PURE__*/function () {
523
765
  writer: writer
524
766
  });
525
767
  }
526
- return _context3.abrupt("return", _types.ExitCode.RuntimeError);
768
+ return _context5.abrupt("return", _types.ExitCode.RuntimeError);
527
769
  case 6:
528
770
  case "end":
529
- return _context3.stop();
771
+ return _context5.stop();
530
772
  }
531
- }, _callee3, null, [[3, 5]]);
773
+ }, _callee5, null, [[3, 5]]);
532
774
  }));
533
775
  return function run() {
534
- return _ref9.apply(this, arguments);
776
+ return _ref13.apply(this, arguments);
535
777
  };
536
778
  }();