@oclif/core 3.14.1 → 3.15.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.
@@ -16,6 +16,16 @@ const formatter_1 = require("./formatter");
16
16
  // written on any platform, that may use \r\n or \n, will be
17
17
  // split on any platform, not just the os specific EOL at runtime.
18
18
  const POSSIBLE_LINE_FEED = /\r\n|\n/;
19
+ /**
20
+ * Determines the sort order of flags. Will default to alphabetical if not set or set to an invalid value.
21
+ */
22
+ function determineSortOrder(flagSortOrder) {
23
+ if (flagSortOrder === 'alphabetical')
24
+ return 'alphabetical';
25
+ if (flagSortOrder === 'none')
26
+ return 'none';
27
+ return 'alphabetical';
28
+ }
19
29
  class CommandHelp extends formatter_1.HelpFormatter {
20
30
  command;
21
31
  config;
@@ -197,12 +207,15 @@ class CommandHelp extends formatter_1.HelpFormatter {
197
207
  }
198
208
  generate() {
199
209
  const cmd = this.command;
200
- const flags = (0, util_1.sortBy)(Object.entries(cmd.flags || {})
210
+ const unsortedFlags = Object.entries(cmd.flags || {})
201
211
  .filter(([, v]) => !v.hidden)
202
212
  .map(([k, v]) => {
203
213
  v.name = k;
204
214
  return v;
205
- }), (f) => [!f.char, f.char, f.name]);
215
+ });
216
+ const flags = determineSortOrder(this.opts.flagSortOrder) === 'alphabetical'
217
+ ? (0, util_1.sortBy)(unsortedFlags, (f) => [!f.char, f.char, f.name])
218
+ : unsortedFlags;
206
219
  const args = Object.values((0, ensure_arg_object_1.ensureArgObject)(cmd.args)).filter((a) => !a.hidden);
207
220
  const output = (0, util_1.compact)(this.sections().map(({ generate, header }) => {
208
221
  const body = generate({ args, cmd, flags }, header);
@@ -4,6 +4,13 @@ export interface HelpOptions {
4
4
  * Use docopts as the usage. Defaults to true.
5
5
  */
6
6
  docopts?: boolean;
7
+ /**
8
+ * Order in which to sort flags in help output. Defaults to `alphabetical`.
9
+ *
10
+ * `alphabetical`: Sort flags alphabetically. All flags with short characters will come first.
11
+ * `none`: Do not sort flags. They will appear in the order in which they were defined on the command.
12
+ */
13
+ flagSortOrder?: 'alphabetical' | 'none';
7
14
  /**
8
15
  * If true, hide command aliases from the root help output. Defaults to false.
9
16
  */
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.14.1",
4
+ "version": "3.15.1",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {
@@ -22,7 +22,7 @@
22
22
  "js-yaml": "^3.14.1",
23
23
  "natural-orderby": "^2.0.3",
24
24
  "object-treeify": "^1.1.33",
25
- "password-prompt": "^1.1.2",
25
+ "password-prompt": "^1.1.3",
26
26
  "slice-ansi": "^4.0.0",
27
27
  "string-width": "^4.2.3",
28
28
  "strip-ansi": "^6.0.1",
@@ -35,29 +35,29 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@commitlint/config-conventional": "^17.8.1",
38
- "@oclif/plugin-help": "^5.2.20",
39
- "@oclif/plugin-plugins": "^3.3.0",
38
+ "@oclif/plugin-help": "^6",
39
+ "@oclif/plugin-plugins": "^4",
40
40
  "@oclif/prettier-config": "^0.2.1",
41
41
  "@oclif/test": "^3.0.3",
42
42
  "@types/ansi-styles": "^3.2.1",
43
- "@types/benchmark": "^2.1.2",
44
- "@types/chai": "^4.3.10",
43
+ "@types/benchmark": "^2.1.5",
44
+ "@types/chai": "^4.3.11",
45
45
  "@types/chai-as-promised": "^7.1.8",
46
46
  "@types/clean-stack": "^2.1.1",
47
- "@types/cli-progress": "^3.11.0",
47
+ "@types/cli-progress": "^3.11.5",
48
48
  "@types/color": "^3.0.5",
49
49
  "@types/debug": "^4.1.10",
50
- "@types/ejs": "^3.1.3",
50
+ "@types/ejs": "^3.1.5",
51
51
  "@types/indent-string": "^4.0.1",
52
52
  "@types/js-yaml": "^3.12.7",
53
- "@types/mocha": "^10.0.2",
53
+ "@types/mocha": "^10.0.6",
54
54
  "@types/node": "^18",
55
55
  "@types/node-notifier": "^8.0.2",
56
56
  "@types/pnpapi": "^0.0.4",
57
57
  "@types/slice-ansi": "^4.0.0",
58
58
  "@types/strip-ansi": "^5.2.1",
59
59
  "@types/supports-color": "^8.1.1",
60
- "@types/wordwrap": "^1.0.1",
60
+ "@types/wordwrap": "^1.0.3",
61
61
  "@types/wrap-ansi": "^3.0.0",
62
62
  "benchmark": "^2.1.4",
63
63
  "chai": "^4.3.10",
@@ -75,9 +75,9 @@
75
75
  "madge": "^6.1.0",
76
76
  "mocha": "^10.2.0",
77
77
  "nyc": "^15.1.0",
78
- "prettier": "^3.0.3",
78
+ "prettier": "^3.1.1",
79
79
  "shx": "^0.3.4",
80
- "sinon": "^16.1.0",
80
+ "sinon": "^16.1.3",
81
81
  "ts-node": "^10.9.1",
82
82
  "tsd": "^0.29.0",
83
83
  "typescript": "^5"