@travetto/cli 4.1.0 → 4.1.1

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 ArcSine Technologies
3
+ Copyright (c) 2020 ArcSine Technologies
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/cli",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "description": "CLI infrastructure for Travetto framework",
5
5
  "keywords": [
6
6
  "cli",
@@ -29,8 +29,8 @@
29
29
  "directory": "module/cli"
30
30
  },
31
31
  "dependencies": {
32
- "@travetto/schema": "^4.1.0",
33
- "@travetto/terminal": "^4.1.0"
32
+ "@travetto/schema": "^4.1.1",
33
+ "@travetto/terminal": "^4.1.1"
34
34
  },
35
35
  "travetto": {
36
36
  "displayName": "Command Line Interface",
package/src/help.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import util from 'node:util';
2
+
1
3
  import { Primitive } from '@travetto/base';
2
- import { StyleUtil } from '@travetto/terminal';
3
4
 
4
5
  import { cliTpl } from './color';
5
6
  import { CliCommandShape } from './types';
@@ -70,8 +71,8 @@ export class HelpUtil {
70
71
  descs.push(desc.join(' '));
71
72
  }
72
73
 
73
- const paramWidths = params.map(x => StyleUtil.cleanText(x).length);
74
- const descWidths = descs.map(x => StyleUtil.cleanText(x).length);
74
+ const paramWidths = params.map(x => util.stripVTControlCharacters(x).length);
75
+ const descWidths = descs.map(x => util.stripVTControlCharacters(x).length);
75
76
 
76
77
  const paramWidth = Math.max(...paramWidths);
77
78
  const descWidth = Math.max(...descWidths);
@@ -99,7 +100,7 @@ export class HelpUtil {
99
100
  static async renderAllHelp(title?: string): Promise<string> {
100
101
  const rows: string[] = [];
101
102
  const keys = [...CliCommandRegistry.getCommandMapping().keys()].sort((a, b) => a.localeCompare(b));
102
- const maxWidth = keys.reduce((a, b) => Math.max(a, StyleUtil.cleanText(b).length), 0);
103
+ const maxWidth = keys.reduce((a, b) => Math.max(a, util.stripVTControlCharacters(b).length), 0);
103
104
 
104
105
  for (const cmd of keys) {
105
106
  try {
@@ -17,12 +17,14 @@ export class CliSchemaCommand implements CliCommandShape {
17
17
  return CliCommandSchemaUtil.getSchema(inst!);
18
18
  }
19
19
 
20
- async validate(name?: string): Promise<CliValidationError | undefined> {
21
- if (name && !CliCommandRegistry.getCommandMapping().has(name)) {
22
- return {
23
- source: 'arg',
24
- message: `name: ${name} is not a valid cli command`
25
- };
20
+ async validate(names: string[]): Promise<CliValidationError | undefined> {
21
+ for (const name of names ?? []) {
22
+ if (name && !CliCommandRegistry.getCommandMapping().has(name)) {
23
+ return {
24
+ source: 'arg',
25
+ message: `name: ${name} is not a valid cli command`
26
+ };
27
+ }
26
28
  }
27
29
  }
28
30
 
@@ -30,15 +32,11 @@ export class CliSchemaCommand implements CliCommandShape {
30
32
  Env.DEBUG.set(false);
31
33
  }
32
34
 
33
- async main(name?: string): Promise<void> {
34
- let output: unknown = undefined;
35
- if (name) {
36
- output = await this.#getSchema(name);
37
- } else {
38
- const names = [...CliCommandRegistry.getCommandMapping().keys()];
39
- const schemas = await Promise.all(names.map(x => this.#getSchema(x)));
40
- output = schemas;
35
+ async main(names?: string[]): Promise<void> {
36
+ if (!names?.length) {
37
+ names = [...CliCommandRegistry.getCommandMapping().keys()];
41
38
  }
42
- await CliUtil.writeAndEnsureComplete(output);
39
+ const resolved = await Promise.all(names.map(x => this.#getSchema(x)));
40
+ await CliUtil.writeAndEnsureComplete(resolved);
43
41
  }
44
42
  }