@optique/run 1.0.0-dev.395 → 1.0.0-dev.401

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/dist/run.cjs CHANGED
@@ -32,7 +32,7 @@ function runImpl(parserOrProgram, options = {}) {
32
32
  footer: program.metadata.footer
33
33
  };
34
34
  } else parser = parserOrProgram;
35
- const { programName = programNameFromProgram ?? node_path.default.basename(node_process.default.argv[1] || "cli"), args = node_process.default.argv.slice(2), colors = node_process.default.stdout.isTTY, maxWidth = node_process.default.stdout.columns, showDefault, showChoices, help, version, completion, aboveError = "usage", errorExitCode = 1, brief = programMetadata?.brief, description = programMetadata?.description, examples = programMetadata?.examples, author = programMetadata?.author, bugs = programMetadata?.bugs, footer = programMetadata?.footer } = options;
35
+ const { programName = programNameFromProgram ?? node_path.default.basename(node_process.default.argv[1] || "cli"), args = node_process.default.argv.slice(2), colors = node_process.default.stdout.isTTY, maxWidth = node_process.default.stdout.columns, showDefault, showChoices, sectionOrder, help, version, completion, aboveError = "usage", errorExitCode = 1, brief = programMetadata?.brief, description = programMetadata?.description, examples = programMetadata?.examples, author = programMetadata?.author, bugs = programMetadata?.bugs, footer = programMetadata?.footer } = options;
36
36
  const helpConfig = help ? typeof help === "string" ? {
37
37
  mode: help,
38
38
  onShow: () => node_process.default.exit(0)
@@ -109,6 +109,7 @@ function runImpl(parserOrProgram, options = {}) {
109
109
  maxWidth,
110
110
  showDefault,
111
111
  showChoices,
112
+ sectionOrder,
112
113
  help: helpConfig,
113
114
  version: versionConfig,
114
115
  completion: completionConfig,
package/dist/run.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ShellCompletion } from "@optique/core/completion";
2
2
  import { InferMode, InferValue, Mode, ModeValue, Parser } from "@optique/core/parser";
3
3
  import { Program } from "@optique/core/program";
4
- import { ShowChoicesOptions, ShowDefaultOptions } from "@optique/core/doc";
4
+ import { DocSection, ShowChoicesOptions, ShowDefaultOptions } from "@optique/core/doc";
5
5
  import { Message } from "@optique/core/message";
6
6
 
7
7
  //#region src/run.d.ts
@@ -62,6 +62,20 @@ interface RunOptions {
62
62
  * @since 0.10.0
63
63
  */
64
64
  readonly showChoices?: boolean | ShowChoicesOptions;
65
+ /**
66
+ * A custom comparator function to control the order of sections in the
67
+ * help output. When provided, it is used instead of the default smart
68
+ * sort (command-only sections first, then mixed, then option/argument-only
69
+ * sections). Sections that compare equal (return `0`) preserve their
70
+ * original relative order.
71
+ *
72
+ * @param a The first section to compare.
73
+ * @param b The second section to compare.
74
+ * @returns A negative number if `a` should appear before `b`, a positive
75
+ * number if `a` should appear after `b`, or `0` if they are equal.
76
+ * @since 1.0.0
77
+ */
78
+ readonly sectionOrder?: (a: DocSection, b: DocSection) => number;
65
79
  /**
66
80
  * Help configuration. Determines how help is made available:
67
81
  *
package/dist/run.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Message } from "@optique/core/message";
2
2
  import { ShellCompletion } from "@optique/core/completion";
3
3
  import { InferMode, InferValue, Mode, ModeValue, Parser } from "@optique/core/parser";
4
4
  import { Program } from "@optique/core/program";
5
- import { ShowChoicesOptions, ShowDefaultOptions } from "@optique/core/doc";
5
+ import { DocSection, ShowChoicesOptions, ShowDefaultOptions } from "@optique/core/doc";
6
6
 
7
7
  //#region src/run.d.ts
8
8
 
@@ -62,6 +62,20 @@ interface RunOptions {
62
62
  * @since 0.10.0
63
63
  */
64
64
  readonly showChoices?: boolean | ShowChoicesOptions;
65
+ /**
66
+ * A custom comparator function to control the order of sections in the
67
+ * help output. When provided, it is used instead of the default smart
68
+ * sort (command-only sections first, then mixed, then option/argument-only
69
+ * sections). Sections that compare equal (return `0`) preserve their
70
+ * original relative order.
71
+ *
72
+ * @param a The first section to compare.
73
+ * @param b The second section to compare.
74
+ * @returns A negative number if `a` should appear before `b`, a positive
75
+ * number if `a` should appear after `b`, or `0` if they are equal.
76
+ * @since 1.0.0
77
+ */
78
+ readonly sectionOrder?: (a: DocSection, b: DocSection) => number;
65
79
  /**
66
80
  * Help configuration. Determines how help is made available:
67
81
  *
package/dist/run.js CHANGED
@@ -31,7 +31,7 @@ function runImpl(parserOrProgram, options = {}) {
31
31
  footer: program.metadata.footer
32
32
  };
33
33
  } else parser = parserOrProgram;
34
- const { programName = programNameFromProgram ?? path.basename(process.argv[1] || "cli"), args = process.argv.slice(2), colors = process.stdout.isTTY, maxWidth = process.stdout.columns, showDefault, showChoices, help, version, completion, aboveError = "usage", errorExitCode = 1, brief = programMetadata?.brief, description = programMetadata?.description, examples = programMetadata?.examples, author = programMetadata?.author, bugs = programMetadata?.bugs, footer = programMetadata?.footer } = options;
34
+ const { programName = programNameFromProgram ?? path.basename(process.argv[1] || "cli"), args = process.argv.slice(2), colors = process.stdout.isTTY, maxWidth = process.stdout.columns, showDefault, showChoices, sectionOrder, help, version, completion, aboveError = "usage", errorExitCode = 1, brief = programMetadata?.brief, description = programMetadata?.description, examples = programMetadata?.examples, author = programMetadata?.author, bugs = programMetadata?.bugs, footer = programMetadata?.footer } = options;
35
35
  const helpConfig = help ? typeof help === "string" ? {
36
36
  mode: help,
37
37
  onShow: () => process.exit(0)
@@ -108,6 +108,7 @@ function runImpl(parserOrProgram, options = {}) {
108
108
  maxWidth,
109
109
  showDefault,
110
110
  showChoices,
111
+ sectionOrder,
111
112
  help: helpConfig,
112
113
  version: versionConfig,
113
114
  completion: completionConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/run",
3
- "version": "1.0.0-dev.395+ace61d13",
3
+ "version": "1.0.0-dev.401+5769648d",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "sideEffects": false,
72
72
  "dependencies": {
73
- "@optique/core": "1.0.0-dev.395+ace61d13"
73
+ "@optique/core": "1.0.0-dev.401+5769648d"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/node": "^20.19.9",