termkit 2.0.2 → 2.1.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.
Files changed (73) hide show
  1. package/README.md +472 -2
  2. package/dist/config.d.ts +11 -0
  3. package/dist/config.d.ts.map +1 -0
  4. package/dist/index.d.ts +47 -96
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +2558 -138
  7. package/dist/index.mjs +2537 -137
  8. package/dist/models/Bar.d.ts +125 -0
  9. package/dist/models/Bar.d.ts.map +1 -0
  10. package/dist/models/Chart.d.ts +106 -0
  11. package/dist/models/Chart.d.ts.map +1 -0
  12. package/dist/models/Column.d.ts +20 -0
  13. package/dist/models/Column.d.ts.map +1 -0
  14. package/dist/models/Command.d.ts +38 -0
  15. package/dist/models/Command.d.ts.map +1 -0
  16. package/dist/models/Input.d.ts +58 -0
  17. package/dist/models/Input.d.ts.map +1 -0
  18. package/dist/models/Log.d.ts +24 -0
  19. package/dist/models/Log.d.ts.map +1 -0
  20. package/dist/models/Markup.d.ts +17 -0
  21. package/dist/models/Markup.d.ts.map +1 -0
  22. package/dist/models/MultiBar.d.ts +17 -0
  23. package/dist/models/MultiBar.d.ts.map +1 -0
  24. package/dist/models/MultiSelect.d.ts +45 -0
  25. package/dist/models/MultiSelect.d.ts.map +1 -0
  26. package/dist/models/Option.d.ts +17 -0
  27. package/dist/models/Option.d.ts.map +1 -0
  28. package/dist/models/Scrollbox.d.ts +20 -0
  29. package/dist/models/Scrollbox.d.ts.map +1 -0
  30. package/dist/models/Select.d.ts +39 -0
  31. package/dist/models/Select.d.ts.map +1 -0
  32. package/dist/models/Spinner.d.ts +67 -0
  33. package/dist/models/Spinner.d.ts.map +1 -0
  34. package/dist/models/Table.d.ts +26 -0
  35. package/dist/models/Table.d.ts.map +1 -0
  36. package/dist/models/TermKit.d.ts +19 -0
  37. package/dist/models/TermKit.d.ts.map +1 -0
  38. package/dist/models/Variable.d.ts +28 -0
  39. package/dist/models/Variable.d.ts.map +1 -0
  40. package/dist/types.d.ts +10 -0
  41. package/dist/types.d.ts.map +1 -0
  42. package/dist/utils/cleanup.d.ts +2 -0
  43. package/dist/utils/cleanup.d.ts.map +1 -0
  44. package/dist/utils/color.d.ts +29 -0
  45. package/dist/utils/color.d.ts.map +1 -0
  46. package/dist/utils/findCommand.d.ts +3 -0
  47. package/dist/utils/findCommand.d.ts.map +1 -0
  48. package/dist/utils/findCommandVariables.d.ts +3 -0
  49. package/dist/utils/findCommandVariables.d.ts.map +1 -0
  50. package/dist/utils/findOption.d.ts +3 -0
  51. package/dist/utils/findOption.d.ts.map +1 -0
  52. package/dist/utils/findOptions.d.ts +3 -0
  53. package/dist/utils/findOptions.d.ts.map +1 -0
  54. package/dist/utils/findVariable.d.ts +5 -0
  55. package/dist/utils/findVariable.d.ts.map +1 -0
  56. package/dist/utils/findVariables.d.ts +3 -0
  57. package/dist/utils/findVariables.d.ts.map +1 -0
  58. package/dist/utils/getVariables.d.ts +3 -0
  59. package/dist/utils/getVariables.d.ts.map +1 -0
  60. package/dist/utils/padLeft.d.ts +2 -0
  61. package/dist/utils/padLeft.d.ts.map +1 -0
  62. package/dist/utils/padRight.d.ts +2 -0
  63. package/dist/utils/padRight.d.ts.map +1 -0
  64. package/dist/utils/padSides.d.ts +2 -0
  65. package/dist/utils/padSides.d.ts.map +1 -0
  66. package/dist/utils/stringLength.d.ts +2 -0
  67. package/dist/utils/stringLength.d.ts.map +1 -0
  68. package/dist/utils/truncate.d.ts +2 -0
  69. package/dist/utils/truncate.d.ts.map +1 -0
  70. package/dist/utils/wrap.d.ts +2 -0
  71. package/dist/utils/wrap.d.ts.map +1 -0
  72. package/package.json +35 -7
  73. package/dist/index.d.mts +0 -99
package/README.md CHANGED
@@ -136,6 +136,463 @@ my-app help
136
136
  my-app serve help
137
137
  ```
138
138
 
139
+ ### Input
140
+
141
+ Interactive text prompt. Supports string, number, integer, boolean, and enum types with validation.
142
+
143
+ ```ts
144
+ import { input, confirm } from 'termkit'
145
+
146
+ const name = await input('Project name?', { default: 'my-app', minLength: 2, maxLength: 20 })
147
+ const port = await input('Port?', { type: 'number', default: 3000, min: 1024, max: 65535 })
148
+ const env = await input('Environment?', { type: 'enum', enum: ['dev', 'staging', 'prod'] })
149
+ ```
150
+
151
+ Use `confirm` as a shorthand for boolean prompts:
152
+
153
+ ```ts
154
+ const deploy = await confirm('Deploy to production?', { default: false })
155
+ ```
156
+
157
+ The text cursor supports left/right arrows, Home/End, Ctrl+A/E, and forward Delete for mid-string editing.
158
+
159
+ Options: `type`, `default`, `placeholder`, `mask`, `inline`, `required`, `min`, `max`, `minLength`, `maxLength`, `enum`, `match`, `regex`, `errorMessage`, `promptColor`, `promptGlyph`, `inputColor`, `errorColor`.
160
+
161
+ ### Select
162
+
163
+ Single-item interactive picker. Navigate with ↑↓ or number keys, confirm with Enter.
164
+
165
+ ```ts
166
+ import { select } from 'termkit'
167
+
168
+ const env = await select('Deploy target?', [
169
+ { label: 'Production', description: 'live traffic' },
170
+ { label: 'Staging', description: 'QA sign-off required' },
171
+ { label: 'Development', description: 'free-for-all' },
172
+ ])
173
+ ```
174
+
175
+ Pass `search: true` to add a type-to-filter input. Typing narrows the list; Backspace removes the last character. Number shortcuts are disabled in search mode — use ↑↓.
176
+
177
+ ```ts
178
+ const pkg = await select('Pick a package:', packages, { search: true })
179
+ ```
180
+
181
+ Pass `maxHeight` to cap the visible rows and enable scrolling. The viewport follows the cursor automatically.
182
+
183
+ ```ts
184
+ const tz = await select('Timezone?', timezones, { maxHeight: 8 })
185
+ ```
186
+
187
+ Both options compose freely:
188
+
189
+ ```ts
190
+ const country = await select('Country?', countries, { search: true, maxHeight: 6 })
191
+ ```
192
+
193
+ Options: `colors`, `colorCycle`, `shimmer`, `skipLabel`, `promptColor`, `promptGlyph`, `descriptionColor`, `selectedPrefix`, `selectedSuffix`, `interval`, `search`, `maxHeight`.
194
+
195
+ ### MultiSelect
196
+
197
+ Multi-item interactive picker. Returns an array of the selected items.
198
+
199
+ ```ts
200
+ import { multiSelect } from 'termkit'
201
+
202
+ const features = await multiSelect('Enable features?', [
203
+ { label: 'Authentication' },
204
+ { label: 'Rate limiting' },
205
+ { label: 'Caching', description: 'Redis-backed' },
206
+ { label: 'Webhooks' },
207
+ ])
208
+ ```
209
+
210
+ Keyboard controls: ↑↓ navigate · Space/Tab toggle · → select · ← deselect · `a` select all · Enter confirm.
211
+
212
+ Enforce selection counts with `min` and `max`:
213
+
214
+ ```ts
215
+ const roles = await multiSelect('Assign roles:', items, { min: 1, max: 3 })
216
+ ```
217
+
218
+ Pass `search: true` to add a type-to-filter input. All printable characters go to the query; `a` select-all is disabled in search mode. Checked items are tracked by their position in the original list so toggling survives filtering.
219
+
220
+ ```ts
221
+ const pkgs = await multiSelect('Add dependencies:', packages, { search: true })
222
+ ```
223
+
224
+ Pass `maxHeight` to cap the visible rows with auto-scrolling:
225
+
226
+ ```ts
227
+ const regions = await multiSelect('Deploy to:', regions, { maxHeight: 6 })
228
+ ```
229
+
230
+ Options: `min`, `max`, `allowSkip`, `colors`, `colorCycle`, `shimmer`, `checkedPrefix`, `uncheckedPrefix`, `promptColor`, `promptGlyph`, `descriptionColor`, `errorColor`, `interval`, `search`, `maxHeight`.
231
+
232
+ ### Log
233
+
234
+ `log` is a singleton logger. `Log` is the class for custom instances.
235
+
236
+ ```ts
237
+ import { log } from 'termkit'
238
+
239
+ log.succeed('Build complete')
240
+ log.fail('Connection refused')
241
+ log.warn('Rate limited, retrying')
242
+ log.info('Listening on port 3000')
243
+ log.data({ user: 'alice', role: 'admin', active: true })
244
+ ```
245
+
246
+ Custom instance with colors:
247
+
248
+ ```ts
249
+ import { Log } from 'termkit'
250
+
251
+ const logger = new Log({ successColor: '#a855f7', failColor: '#ef4444' })
252
+ logger.succeed('Custom color')
253
+ ```
254
+
255
+ ### markup
256
+
257
+ Pretty-prints any value with syntax coloring — strings, numbers, booleans, `null`, `Date`, nested objects, and arrays.
258
+
259
+ ```ts
260
+ import { markup } from 'termkit'
261
+
262
+ console.log(markup({ name: 'alice', roles: ['admin', 'editor'], active: true }))
263
+ ```
264
+
265
+ Custom styles and value translations:
266
+
267
+ ```ts
268
+ import { markup, Color } from 'termkit'
269
+
270
+ const out = markup(data, {
271
+ styles: {
272
+ number: (v) => Color.hex('#f97316')(v),
273
+ boolean: (v) => Color.hex('#a855f7')(v),
274
+ },
275
+ translations: {
276
+ createdAt: (v) => new Date(v as string),
277
+ },
278
+ })
279
+ console.log(out)
280
+ ```
281
+
282
+ ### Table
283
+
284
+ Renders tabular data with auto-sized columns, optional titles, alignment, and meta rows.
285
+
286
+ ```ts
287
+ import { Table } from 'termkit'
288
+
289
+ const rows = [
290
+ { name: 'Alice', role: 'admin', active: true },
291
+ { name: 'Bob', role: 'editor', active: false },
292
+ ]
293
+
294
+ new Table(rows).print()
295
+ ```
296
+
297
+ Column configuration — pass a `columns` array to control ordering, titles, alignment, and value formatting:
298
+
299
+ ```ts
300
+ new Table(rows, {
301
+ title: 'Users',
302
+ columns: [
303
+ { key: 'name', title: 'Name' },
304
+ { key: 'role', title: 'Role', align: 'center' },
305
+ { key: 'active', title: 'Active', value: (v) => (v ? 'yes' : 'no'), align: 'right' },
306
+ ],
307
+ separator: ' ',
308
+ }).print()
309
+ ```
310
+
311
+ Global alignment, margin, and meta rows (rendered below a separator after the data rows):
312
+
313
+ ```ts
314
+ new Table(rows, {
315
+ align: Table.center, // Table.left | Table.center | Table.right
316
+ margin: 1, // extra space added to each column's padding
317
+ meta: [{ name: 'Total', role: '', active: '' }],
318
+ }).print()
319
+ ```
320
+
321
+ Passing a string shorthand instead of a `ColumnOptions` object uses the key as both key and title:
322
+
323
+ ```ts
324
+ new Table(rows, { columns: ['name', 'role'] }).print()
325
+ ```
326
+
327
+ ### Chart
328
+
329
+ The `Chart` namespace provides horizontal bar, vertical column, heatmap, and scatter visualizations. Every chart class has a `.print()` method that writes to stdout and a `.toString()` method that returns the rendered string.
330
+
331
+ All chart constructors accept optional `paddingX` and `paddingY` options to add whitespace around the output.
332
+
333
+ #### Chart.Bar
334
+
335
+ Horizontal bar chart. Each item maps a label to a value; the bar width scales to fill the terminal.
336
+
337
+ ```ts
338
+ import { Chart } from 'termkit'
339
+
340
+ new Chart.Bar([
341
+ { key: 'Mon', value: 42 },
342
+ { key: 'Tue', value: 67 },
343
+ { key: 'Wed', value: 31 },
344
+ ]).print()
345
+ ```
346
+
347
+ Custom style and `null` gaps (blank rows):
348
+
349
+ ```ts
350
+ import { Chart, Color } from 'termkit'
351
+
352
+ new Chart.Bar([
353
+ { key: 'Errors', value: 12, style: Color.red },
354
+ { key: 'Warnings', value: 45, style: Color.yellow },
355
+ null,
356
+ { key: 'OK', value: 89, style: Color.green },
357
+ ]).print()
358
+ ```
359
+
360
+ Pass `character` to use a custom fill character instead of a solid block:
361
+
362
+ ```ts
363
+ new Chart.Bar([
364
+ { key: 'CPU', value: 72, character: '▪' },
365
+ { key: 'RAM', value: 55, character: '▪' },
366
+ ]).print()
367
+ ```
368
+
369
+ Pass `width` to override the terminal column width used for scaling:
370
+
371
+ ```ts
372
+ new Chart.Bar(data, { width: 60, paddingX: 2, paddingY: 1 }).print()
373
+ ```
374
+
375
+ #### Chart.VerticalBar
376
+
377
+ Vertical column chart using Unicode block characters with fractional height resolution.
378
+
379
+ ```ts
380
+ new Chart.VerticalBar([
381
+ { key: 'M', value: 10 },
382
+ { key: 'T', value: 25 },
383
+ { key: 'W', value: 18 },
384
+ { key: 'T', value: 30 },
385
+ { key: 'F', value: 22 },
386
+ ], { height: 8, colWidth: 3 }).print()
387
+ ```
388
+
389
+ Pass `null` items to insert gaps between column groups:
390
+
391
+ ```ts
392
+ new Chart.VerticalBar([
393
+ { key: 'A', value: 15, style: Color.blue },
394
+ { key: 'B', value: 28, style: Color.blue },
395
+ null,
396
+ { key: 'C', value: 10, style: Color.magenta },
397
+ ], { height: 10 }).print()
398
+ ```
399
+
400
+ Pass `width` to have `colWidth` auto-calculated to fill a fixed total width:
401
+
402
+ ```ts
403
+ new Chart.VerticalBar(data, { width: 40, height: 12 }).print()
404
+ ```
405
+
406
+ #### Chart.Heatmap
407
+
408
+ 2-D grid colored by value intensity between a configurable low and high color.
409
+
410
+ ```ts
411
+ new Chart.Heatmap(
412
+ [
413
+ [1, 5, 9, 3],
414
+ [2, 6, 3, 8],
415
+ [8, 4, 7, 2],
416
+ ],
417
+ {
418
+ rowLabels: ['Row A', 'Row B', 'Row C'],
419
+ colLabels: ['C1', 'C2', 'C3', 'C4'],
420
+ colors: ['#0000ff', '#ff0000'],
421
+ }
422
+ ).print()
423
+ ```
424
+
425
+ Multi-stop color scale and explicit range:
426
+
427
+ ```ts
428
+ new Chart.Heatmap(data, {
429
+ colors: ['#0000ff', '#00ffff', '#ffff00', '#ff0000'],
430
+ min: 0,
431
+ max: 100,
432
+ cellWidth: 3,
433
+ }).print()
434
+ ```
435
+
436
+ #### Chart.Scatter
437
+
438
+ 2-D scatter plot with optional labeled axes. Points outside the plot bounds are silently clipped.
439
+
440
+ ```ts
441
+ new Chart.Scatter([
442
+ { x: 1, y: 2 },
443
+ { x: 3, y: 5 },
444
+ { x: 7, y: 3 },
445
+ ]).print()
446
+ ```
447
+
448
+ Custom characters, per-point styles, and explicit axis bounds:
449
+
450
+ ```ts
451
+ import { Chart, Color } from 'termkit'
452
+
453
+ new Chart.Scatter([
454
+ { x: 10, y: 20, character: '●', style: Color.green },
455
+ { x: 30, y: 50, character: '●', style: Color.red },
456
+ ], {
457
+ width: 60,
458
+ height: 20,
459
+ xMin: 0,
460
+ xMax: 40,
461
+ yMin: 0,
462
+ yMax: 60,
463
+ }).print()
464
+ ```
465
+
466
+ Disable axes for a raw grid output:
467
+
468
+ ```ts
469
+ new Chart.Scatter(data, { axes: false }).print()
470
+ ```
471
+
472
+ #### Chart.Line
473
+
474
+ Line chart that interpolates between data points. Accepts the same axis options as `Chart.Scatter`.
475
+
476
+ ```ts
477
+ import { Chart } from 'termkit'
478
+
479
+ new Chart.Line(
480
+ Array.from({ length: 40 }, (_, i) => ({ x: i, y: Math.sin(i * 0.3) * 4 })),
481
+ { height: 12 }
482
+ ).print()
483
+ ```
484
+
485
+ Per-point styles and optional fill below the line:
486
+
487
+ ```ts
488
+ import { Chart, Color } from 'termkit'
489
+
490
+ new Chart.Line(data, { fill: true, style: (s) => Color.cyan(s) }).print()
491
+ ```
492
+
493
+ Options: `width`, `height`, `xMin`, `xMax`, `yMin`, `yMax`, `character`, `axes`, `fill`, `paddingX`, `paddingY`.
494
+
495
+ #### Chart.Sparkline
496
+
497
+ Returns a single-line sparkline string using Unicode block characters. Useful for inline metrics.
498
+
499
+ ```ts
500
+ import { Chart, Color } from 'termkit'
501
+
502
+ const samples = [12, 45, 23, 67, 89, 55, 34, 78, 61]
503
+ console.log('CPU ' + Chart.Sparkline(samples, { style: (s) => Color.green(s) }))
504
+ // CPU ▁▃▁▅█▄▂▆▄
505
+ ```
506
+
507
+ Options: `min`, `max`, `style`.
508
+
509
+ ### Bar — ETA and rate tracking
510
+
511
+ Attach progress tracking to an animated `Bar` with `.track()` and `.tick()`.
512
+
513
+ ```ts
514
+ import { Bar } from 'termkit'
515
+
516
+ const total = 500
517
+ const bar = new Bar({ progress: 0 })
518
+ bar.track(total, { showRate: true, showEta: true, unit: 'files' })
519
+ bar.message('Processing…')
520
+ bar.start()
521
+
522
+ for await (const item of items) {
523
+ await process(item)
524
+ bar.tick()
525
+ }
526
+
527
+ bar.stop()
528
+ bar.succeed(`Done — ${total} files processed`)
529
+ ```
530
+
531
+ Each `tick(n?)` increments the completed count, updates `progress`, and appends a live `12.3/s · ETA 8s` suffix that shrinks the bar to keep the full line within terminal width.
532
+
533
+ Raw values are available as getters at any time:
534
+
535
+ ```ts
536
+ bar.rate // units per second (number)
537
+ bar.eta // estimated seconds remaining (number)
538
+ ```
539
+
540
+ Options on `track(total, opts?)`: `unit` (label appended to rate), `showRate` (default `true`), `showEta` (default `true`). Both can also be set via constructor: `new Bar({ showRate: true, showEta: true, rateUnit: 'MB' })`.
541
+
542
+ ### MultiBar
543
+
544
+ Renders multiple `Bar` instances as a synchronized block. Each bar animates independently; calling `.succeed()`, `.fail()`, `.warn()`, or `.info()` on a bar freezes that line while the others keep running. The group stops automatically when every bar is finalized.
545
+
546
+ ```ts
547
+ import { MultiBar, Bar } from 'termkit'
548
+
549
+ const multi = new MultiBar()
550
+ const download = multi.add({ text: 'Downloading', progress: 0, colors: Bar.COLORS.cool })
551
+ const build = multi.add({ text: 'Building', progress: 0, colors: Bar.COLORS.heat })
552
+ const deploy = multi.add({ text: 'Deploying' }) // indeterminate until started
553
+
554
+ multi.start()
555
+
556
+ await runDownload(p => { download.progress = p })
557
+ download.succeed('Downloaded')
558
+
559
+ await runBuild(p => { build.progress = p })
560
+ build.succeed('Built')
561
+
562
+ deploy.progress = 0
563
+ await runDeploy(p => { deploy.progress = p })
564
+ deploy.succeed('Deployed')
565
+
566
+ multi.stop()
567
+ ```
568
+
569
+ Each `add()` call accepts the same options as `Bar` and returns a `Bar` instance — `.message()`, `.tick()`, `.track()`, `.progress`, and the completion methods all work the same way. Bars must be added before `.start()`.
570
+
571
+ Options: `interval`.
572
+
573
+ ### truncate
574
+
575
+ ANSI-aware string truncation. Measures visible length ignoring escape codes, and appends a configurable suffix.
576
+
577
+ ```ts
578
+ import { truncate } from 'termkit'
579
+
580
+ truncate('The quick brown fox jumps over the lazy dog', 20)
581
+ // 'The quick brown fox…'
582
+
583
+ truncate(coloredString, 40, ' [more]')
584
+ ```
585
+
586
+ ### wrap
587
+
588
+ ANSI-aware word wrap. Breaks at spaces to keep each line within a given column width.
589
+
590
+ ```ts
591
+ import { wrap } from 'termkit'
592
+
593
+ console.log(wrap(longParagraph, 60))
594
+ ```
595
+
139
596
  ## API
140
597
 
141
598
  ### Functions
@@ -147,14 +604,27 @@ my-app serve help
147
604
  | `middleware` | `(fn) => fn` | Identity helper for typing middleware inline |
148
605
  | `parse` | `(argv) => Promise<unknown>` | Parse using the root command |
149
606
  | `setDefaults` | `(defaults) => void` | Set defaults applied to all new commands |
607
+ | `configure` | `(opts) => void` | Set global display options (color, glyphs) |
608
+ | `markup` | `(data, options?) => string` | Pretty-print a value with syntax coloring |
609
+ | `input` | `(prompt, options?) => Promise<string \| number \| boolean \| null>` | Interactive text prompt |
610
+ | `confirm` | `(prompt, options?) => Promise<boolean \| null>` | Boolean yes/no prompt |
611
+ | `select` | `(prompt, items, options?) => Promise<T \| null>` | Single-item interactive picker |
612
+ | `multiSelect` | `(prompt, items, options?) => Promise<T[] \| null>` | Multi-item interactive picker |
613
+ | `Chart.Sparkline` | `(data, options?) => string` | Single-line sparkline string |
614
+ | `truncate` | `(s, maxLength, suffix?) => string` | ANSI-aware string truncation |
615
+ | `wrap` | `(s, width) => string` | ANSI-aware word wrap |
616
+ | `padLeft` | `(s, width) => string` | Right-align a string within a fixed width |
617
+ | `padRight` | `(s, width) => string` | Left-align a string within a fixed width |
618
+ | `padSides` | `(s, width) => string` | Center a string within a fixed width |
619
+ | `stringLength` | `(s) => number` | Visual length of a string, stripping ANSI escape codes |
150
620
 
151
621
  ### Classes
152
622
 
153
- `Command`, `Option`, `Variable`, `TermKit`
623
+ `Command`, `Option`, `Variable`, `TermKit`, `Bar`, `MultiBar`, `Spinner`, `Input`, `Select`, `MultiSelect`, `Log`, `Table`, `Column`, `Chart.Bar`, `Chart.VerticalBar`, `Chart.Heatmap`, `Chart.Scatter`, `Chart.Line`
154
624
 
155
625
  ### Types
156
626
 
157
- `ActionFn`, `MiddlewareFn`, `ParsedOptions`, `CommandDefaults`, `VariableType`
627
+ `ActionFn`, `MiddlewareFn`, `ParsedOptions`, `CommandDefaults`, `VariableType`, `BarMode`, `BarOptions`, `MultiBarOptions`, `SpinnerOptions`, `InputOptions`, `InputReturn`, `InputType`, `SelectItem`, `SelectOptions`, `MultiSelectItem`, `MultiSelectOptions`, `LogOptions`, `TableOptions`, `ColumnOptions`, `ColumnAlign`, `MarkupOptions`, `MarkupStyleFn`, `MarkupStyles`, `HelpColor`, `Chart.BarItem`, `Chart.BarOptions`, `Chart.VerticalBarItem`, `Chart.VerticalBarOptions`, `Chart.HeatmapOptions`, `Chart.ScatterPoint`, `Chart.ScatterOptions`, `Chart.LinePoint`, `Chart.LineOptions`, `Chart.SparklineOptions`
158
628
 
159
629
  ## Authors
160
630
 
@@ -0,0 +1,11 @@
1
+ export type HelpColor = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | number | `#${string}`;
2
+ interface TermKitConfig {
3
+ color: HelpColor;
4
+ pulseColors: string[];
5
+ glyphs: boolean;
6
+ interactive: boolean;
7
+ }
8
+ export declare const config: TermKitConfig;
9
+ export declare function configure(opts: Partial<TermKitConfig>): void;
10
+ export {};
11
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,MAAM,EAAE,CAAA;AAI5H,UAAU,aAAa;IACrB,KAAK,EAAE,SAAS,CAAA;IAChB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,MAAM,EAAE,OAAO,CAAA;IACf,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,eAAO,MAAM,MAAM,EAAE,aAKpB,CAAA;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAK5D"}
package/dist/index.d.ts CHANGED
@@ -1,99 +1,50 @@
1
- type VariableType = 'string' | 'number' | 'boolean';
2
- interface ParsedOptions {
3
- _source: string[];
4
- _parents?: Record<string, Record<string, unknown>>;
5
- [key: string]: unknown;
6
- }
7
- type ActionFn = (options: ParsedOptions) => unknown | Promise<unknown>;
8
- type MiddlewareFn = (options: ParsedOptions) => void | Promise<void>;
9
-
10
- interface VariableData {
11
- array?: boolean;
12
- name?: string;
13
- raw?: string;
14
- required?: boolean;
15
- type?: VariableType;
16
- }
17
- declare class Variable {
18
- array: boolean;
19
- name: string | null;
20
- raw: string | null;
21
- required: boolean;
22
- type: VariableType;
23
- value: unknown[] | null;
24
- constructor(data?: VariableData);
25
- }
26
-
27
- interface OptionData {
28
- short?: string | null;
29
- long?: string | null;
30
- info?: string | null;
31
- variables?: string | null;
32
- }
33
- declare class Option {
34
- short: string | null;
35
- long: string | null;
36
- info: string | null;
37
- variables: Variable[] | null;
38
- constructor(data?: OptionData);
39
- description(info: string): this;
40
- }
41
-
42
- interface CommandData {
43
- name?: string;
44
- variables?: string | null;
45
- info?: string;
46
- middlewares?: MiddlewareFn[];
47
- options?: Option[];
48
- }
49
- declare class Command {
50
- actionFunction: ActionFn | null;
51
- commandsArray: Command[];
52
- commandStrings: string[];
53
- info: string | null;
54
- middlewaresArray: MiddlewareFn[];
55
- name: string | null;
56
- optionsArray: Option[];
57
- variables: Variable[] | null;
58
- versionString: string | null;
59
- constructor(data?: CommandData);
60
- description(info: string): this;
61
- variable(string: string): this;
62
- action(fn: ActionFn): this;
63
- command(cmd: Command): this;
64
- commands(cmds: Command[]): this;
65
- middleware(fn: MiddlewareFn): this;
66
- middlewares(fns: MiddlewareFn[]): this;
67
- option(short: string | null, long: string | null, variables: string | null, info: string): this;
68
- options(opts: Option[]): this;
69
- version(v: string): this;
70
- help(_source?: string[]): void;
71
- parse(input: string[]): Promise<unknown>;
72
- }
73
-
74
- interface TermKitDefaults {
75
- middlewares?: MiddlewareFn[];
76
- options?: Option[];
77
- }
78
- declare class TermKit {
79
- private static base;
80
- private static commandDefaults;
81
- static set defaults(obj: TermKitDefaults);
82
- static setDefaults(obj: TermKitDefaults): void;
83
- static command(name: string, variables?: string | null, info?: string): Command;
84
- static middleware(action: MiddlewareFn): MiddlewareFn;
85
- static option(short: string | null, long: string | null, variables: string | null, info: string): Option;
86
- static parse(arr: string[]): Promise<unknown>;
87
- }
88
-
89
- interface CommandDefaults {
1
+ import { Command } from '@/models/Command';
2
+ import { Option } from '@/models/Option';
3
+ import type { MiddlewareFn } from '@/types';
4
+ export type { HelpColor } from '@/config';
5
+ export { configure } from '@/config';
6
+ export type { BarMode, BarOptions } from '@/models/Bar';
7
+ export { Bar } from '@/models/Bar';
8
+ export * as Chart from '@/models/Chart';
9
+ export type { ColumnAlign, ColumnOptions } from '@/models/Column';
10
+ export { Column } from '@/models/Column';
11
+ export { Command } from '@/models/Command';
12
+ export type { InputOptions, InputReturn, InputType } from '@/models/Input';
13
+ export { confirm, Input, input } from '@/models/Input';
14
+ export type { LogOptions } from '@/models/Log';
15
+ export { Log, log } from '@/models/Log';
16
+ export type { MarkupOptions, MarkupStyleFn, MarkupStyles } from '@/models/Markup';
17
+ export { markup } from '@/models/Markup';
18
+ export type { MultiBarOptions } from '@/models/MultiBar';
19
+ export { MultiBar } from '@/models/MultiBar';
20
+ export type { MultiSelectItem, MultiSelectOptions } from '@/models/MultiSelect';
21
+ export { MultiSelect, multiSelect } from '@/models/MultiSelect';
22
+ export { Option } from '@/models/Option';
23
+ export type { ScrollboxOptions } from '@/models/Scrollbox';
24
+ export { Scrollbox, scrollbox } from '@/models/Scrollbox';
25
+ export type { SelectItem, SelectOptions } from '@/models/Select';
26
+ export { Select, select } from '@/models/Select';
27
+ export type { SpinnerOptions } from '@/models/Spinner';
28
+ export { Spinner } from '@/models/Spinner';
29
+ export type { TableOptions } from '@/models/Table';
30
+ export { Table } from '@/models/Table';
31
+ export { TermKit } from '@/models/TermKit';
32
+ export { Variable } from '@/models/Variable';
33
+ export type { ActionFn, MiddlewareFn, ParsedOptions, VariableType } from '@/types';
34
+ export { padLeft } from '@/utils/padLeft';
35
+ export { padRight } from '@/utils/padRight';
36
+ export { padSides } from '@/utils/padSides';
37
+ export { stringLength } from '@/utils/stringLength';
38
+ export { truncate } from '@/utils/truncate';
39
+ export { wrap } from '@/utils/wrap';
40
+ export { default as Color } from 'cosmetic';
41
+ export interface CommandDefaults {
90
42
  middlewares?: MiddlewareFn[];
91
43
  options?: Option[];
92
44
  }
93
- declare const command: (name: string, variables?: string | null, info?: string) => Command;
94
- declare const middleware: (fn: MiddlewareFn) => MiddlewareFn;
95
- declare const option: (short: string | null, long: string | null, variables: string | null, info: string) => Option;
96
- declare const parse: (arr: string[]) => Promise<unknown>;
97
- declare const setDefaults: (data: CommandDefaults) => void;
98
-
99
- export { type ActionFn, Command, type CommandDefaults, type MiddlewareFn, Option, type ParsedOptions, TermKit, Variable, type VariableType, command, middleware, option, parse, setDefaults };
45
+ export declare const command: (name: string, variables?: string | null, info?: string) => Command;
46
+ export declare const middleware: (fn: MiddlewareFn) => MiddlewareFn;
47
+ export declare const option: (short: string | null, long: string | null, variables: string | null, info: string) => Option;
48
+ export declare const parse: (arr: string[]) => Promise<void>;
49
+ export declare const setDefaults: (data: CommandDefaults) => void;
50
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAClC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAA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