@memlab/cli 1.0.40 → 1.0.41

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.
@@ -108,10 +108,10 @@ class CheckLeakCommand extends BaseCommand_1.default {
108
108
  showWorkingDirErrorMessageAndHalt() {
109
109
  throw core_1.utils.haltOrThrow('No control or test working directory or snapshot location specified, ' +
110
110
  'please specify them via: \n' +
111
- ` --${new SetControlSnapshotOption_1.default().getOptionName()} with ` +
111
+ ` --${new SetControlSnapshotOption_1.default().getOptionName()} and` +
112
112
  ` --${new SetTreatmentSnapshotOption_1.default().getOptionName()}\n` +
113
113
  'alternatively, you can also specify them via: \n' +
114
- ` --${new SetControlWorkDirOption_1.default().getOptionName()} with ` +
114
+ ` --${new SetControlWorkDirOption_1.default().getOptionName()} and` +
115
115
  ` --${new SetTreatmentWorkDirOption_1.default().getOptionName()}`);
116
116
  }
117
117
  getWorkDirs(options) {
@@ -202,8 +202,8 @@ class HelperCommand extends BaseCommand_1.default {
202
202
  const cmd = DocUtils_1.default.generateExampleCommand(name, example, {
203
203
  descriptionAsBashComment: false,
204
204
  });
205
- let msg = `${indent}${cmd}`;
206
- msg += `\n${indent}${desc}`;
205
+ let msg = DocUtils_1.default.indentText(cmd, indent);
206
+ msg += `\n${DocUtils_1.default.indentText(desc, indent)}`;
207
207
  if (options.printOptions && cmdDoc.length > 0) {
208
208
  const cmdDocBlock = (0, CLIUtils_1.alignTextInBlock)(cmdDoc, {
209
209
  leftIndent: indent.length + 2,
@@ -12,7 +12,9 @@ type GenerateExampleCommandOption = {
12
12
  descriptionAsBashComment?: boolean;
13
13
  };
14
14
  declare function generateExampleCommand(command: string, cliExample: CommandOptionExample, options?: GenerateExampleCommandOption): string;
15
+ declare function indentText(description: string, indent: string): string;
15
16
  declare const _default: {
17
+ indentText: typeof indentText;
16
18
  generateExampleCommand: typeof generateExampleCommand;
17
19
  };
18
20
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"DocUtils.d.ts","sourceRoot":"","sources":["../../../../src/commands/helper/lib/DocUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAEvD,KAAK,4BAA4B,GAAG;IAClC,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,iBAAS,sBAAsB,CAC7B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,oBAAoB,EAChC,OAAO,GAAE,4BAAiC,GACzC,MAAM,CA2BR;;;;AASD,wBAEE"}
1
+ {"version":3,"file":"DocUtils.d.ts","sourceRoot":"","sources":["../../../../src/commands/helper/lib/DocUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAEvD,KAAK,4BAA4B,GAAG;IAClC,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,iBAAS,sBAAsB,CAC7B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,oBAAoB,EAChC,OAAO,GAAE,4BAAiC,GACzC,MAAM,CA2BR;AAaD,iBAAS,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CA2D/D;;;;;AAED,wBAGE"}
@@ -34,6 +34,71 @@ function generateExampleCommand(command, cliExample, options = {}) {
34
34
  function exampleFromCliOptionString(command, cliExample) {
35
35
  return `memlab ${command} ${cliExample.trim()}`;
36
36
  }
37
+ function getCLIWidth() {
38
+ return process.stdout.columns || 80; // Default to 80 if undefined
39
+ }
40
+ function indentText(description, indent) {
41
+ const cliWidth = getCLIWidth();
42
+ const availableWidth = cliWidth - indent.length;
43
+ const lines = [];
44
+ // Split the description by \n to handle existing line breaks
45
+ const descriptionLines = description.split('\n');
46
+ descriptionLines.forEach(descLine => {
47
+ const words = descLine.split(/\s+/);
48
+ let line = '';
49
+ for (let i = 0; i < words.length; i++) {
50
+ const word = words[i];
51
+ if (line.length === 0) {
52
+ // Start a new line with the word
53
+ if (word.length > availableWidth) {
54
+ // The word itself is longer than the available width
55
+ // Split the word
56
+ let start = 0;
57
+ while (start < word.length) {
58
+ const part = word.substring(start, start + availableWidth);
59
+ lines.push(indent + part);
60
+ start += availableWidth;
61
+ }
62
+ line = '';
63
+ }
64
+ else {
65
+ line = word;
66
+ }
67
+ }
68
+ else {
69
+ const potentialLine = line + ' ' + word;
70
+ if (potentialLine.length <= availableWidth) {
71
+ line = potentialLine;
72
+ }
73
+ else {
74
+ // Line is full, push it and start new line
75
+ lines.push(indent + line);
76
+ if (word.length > availableWidth) {
77
+ // The word itself is longer than the available width
78
+ // Split the word
79
+ let start = 0;
80
+ while (start < word.length) {
81
+ const part = word.substring(start, start + availableWidth);
82
+ lines.push(indent + part);
83
+ start += availableWidth;
84
+ }
85
+ line = '';
86
+ }
87
+ else {
88
+ line = word;
89
+ }
90
+ }
91
+ }
92
+ }
93
+ // Push the last line if any
94
+ if (line.length > 0) {
95
+ lines.push(indent + line);
96
+ }
97
+ });
98
+ // Join all lines with \n
99
+ return lines.join('\n');
100
+ }
37
101
  exports.default = {
102
+ indentText,
38
103
  generateExampleCommand,
39
104
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memlab/cli",
3
- "version": "1.0.40",
3
+ "version": "1.0.41",
4
4
  "license": "MIT",
5
5
  "description": "command line interface for memlab",
6
6
  "author": "Liang Gong <lgong@fb.com>",
@@ -26,10 +26,10 @@
26
26
  "access": "public"
27
27
  },
28
28
  "dependencies": {
29
- "@memlab/api": "^1.0.37",
30
- "@memlab/core": "^1.1.38",
31
- "@memlab/e2e": "^1.0.38",
32
- "@memlab/heap-analysis": "^1.0.35",
29
+ "@memlab/api": "^1.0.38",
30
+ "@memlab/core": "^1.1.39",
31
+ "@memlab/e2e": "^1.0.39",
32
+ "@memlab/heap-analysis": "^1.0.36",
33
33
  "ansi": "^0.3.1",
34
34
  "babar": "^0.2.0",
35
35
  "blessed": "^0.1.81",