@oclif/core 3.26.9 → 3.27.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.
@@ -154,12 +154,7 @@ class CommandHelp extends formatter_1.HelpFormatter {
154
154
  label = labels.join(flag.char ? (0, theme_1.colorize)(this.config?.theme?.flagSeparator, ', ') : ' ');
155
155
  }
156
156
  if (flag.type === 'option') {
157
- let value = flag.helpValue || (this.opts.showFlagNameInTitle ? flag.name : '<value>');
158
- if (!flag.helpValue && flag.options) {
159
- value = showOptions || this.opts.showFlagOptionsInTitle ? `${flag.options.join('|')}` : '<option>';
160
- }
161
- if (flag.multiple)
162
- value += '...';
157
+ let value = docopts_1.DocOpts.formatUsageType(flag, this.opts.showFlagNameInTitle ?? false, this.opts.showFlagOptionsInTitle ?? showOptions);
163
158
  if (!value.includes('|'))
164
159
  value = chalk_1.default.underline(value);
165
160
  label += `=${value}`;
@@ -60,6 +60,7 @@ export declare class DocOpts {
60
60
  private flagList;
61
61
  private flagMap;
62
62
  constructor(cmd: Command.Loadable);
63
+ static formatUsageType(flag: Command.Flag.Any, showFlagName: boolean, showOptions: boolean): string;
63
64
  static generate(cmd: Command.Loadable): string;
64
65
  toString(): string;
65
66
  private combineElementsToFlag;
@@ -73,6 +73,27 @@ class DocOpts {
73
73
  return flag;
74
74
  });
75
75
  }
76
+ static formatUsageType(flag, showFlagName, showOptions) {
77
+ if (flag.type !== 'option')
78
+ return '';
79
+ let helpValues;
80
+ if (flag.helpValue) {
81
+ // if there is a given helpValue, use it
82
+ helpValues = typeof flag.helpValue === 'string' ? [flag.helpValue] : flag.helpValue;
83
+ }
84
+ else if (flag.options) {
85
+ // if there are options, show them if wanted
86
+ helpValues = [showOptions ? flag.options.join('|') : '<option>'];
87
+ }
88
+ else if (showFlagName) {
89
+ helpValues = [flag.name];
90
+ }
91
+ else {
92
+ // default to <value>
93
+ helpValues = ['<value>'];
94
+ }
95
+ return helpValues.map((v) => `${v}${flag.multiple ? '...' : ''}`).join(' ');
96
+ }
76
97
  static generate(cmd) {
77
98
  return new DocOpts(cmd).toString();
78
99
  }
@@ -93,7 +114,7 @@ class DocOpts {
93
114
  const name = flag.char ? `-${flag.char}` : `--${flag.name}`;
94
115
  if (flag.type === 'boolean')
95
116
  return name;
96
- return `${name}=<value>`;
117
+ return `${name}=${DocOpts.formatUsageType(flag, false, true)}`;
97
118
  }));
98
119
  }
99
120
  return opts.join(' ');
@@ -123,7 +144,7 @@ class DocOpts {
123
144
  // not all flags have short names
124
145
  const flagName = flag.char ? `-${flag.char}` : `--${flag.name}`;
125
146
  if (flag.type === 'option') {
126
- type = flag.options ? ` ${flag.options.join('|')}` : ' <value>';
147
+ type = ` ${DocOpts.formatUsageType(flag, false, true)}`;
127
148
  }
128
149
  const element = `${flagName}${type}`;
129
150
  elementMap[flag.name] = element;
@@ -198,7 +198,7 @@ export type BooleanFlagProps = FlagProps & {
198
198
  };
199
199
  export type OptionFlagProps = FlagProps & {
200
200
  type: 'option';
201
- helpValue?: string;
201
+ helpValue?: string | string[];
202
202
  options?: readonly string[];
203
203
  multiple?: boolean;
204
204
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "3.26.9",
4
+ "version": "3.27.0",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {