Skip to content

Commit 49cc426

Browse files
update to use long name not name and fix up fullable fields, and use … (#1905)
1 parent 46f6524 commit 49cc426

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

_includes/renderCommand.tsx

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,15 @@ import { HeaderAnchor } from "../_components/HeaderAnchor.tsx";
44
import CLI_REFERENCE from "../runtime/reference/cli/_commands_reference.json" with {
55
type: "json",
66
};
7-
import { VNode } from "npm:preact";
87

98
type ArgType = {
109
name: string;
11-
help: string;
12-
short:
13-
| string
14-
| number
15-
| bigint
16-
| boolean
17-
| object
18-
| VNode<any>
19-
| null
20-
| undefined;
10+
short: string | null;
11+
long: string;
12+
required: boolean;
13+
help: string | null;
14+
help_heading: string | null;
15+
usage: string;
2116
};
2217

2318
const ANSI_RE = ansiRegex();
@@ -45,7 +40,7 @@ function flagsToInlineCode(text: string): string {
4540
export default function renderCommand(
4641
commandName: string,
4742
helpers: Lume.Helpers,
48-
): { rendered: any; toc: TableOfContentsItem_[] } {
43+
): { rendered: JSX.Element; toc: TableOfContentsItem_[] } {
4944
const command = CLI_REFERENCE.subcommands.find((command) =>
5045
command.name === commandName
5146
)!;
@@ -144,7 +139,7 @@ export default function renderCommand(
144139
const id = heading.toLowerCase().replace(/\s/g, "-");
145140

146141
const renderedFlags = flags.toSorted((a: ArgType, b: ArgType) =>
147-
a.name.localeCompare(b.name)
142+
a.long.localeCompare(b.long)
148143
).map((flag: ArgType) => renderOption(id, flag, helpers));
149144

150145
toc.push({
@@ -172,7 +167,7 @@ export default function renderCommand(
172167
}
173168

174169
function renderOption(group: string, arg: ArgType, helpers: Lume.Helpers) {
175-
const id = `${group}-${arg.name}`;
170+
const id = `${group}-${arg.long}`;
176171

177172
let docsLink = null;
178173
// Add null check for arg.help
@@ -195,8 +190,8 @@ function renderOption(group: string, arg: ArgType, helpers: Lume.Helpers) {
195190
<h3 id={id}>
196191
<code>
197192
{docsLink
198-
? <a href={docsLink}>{"--" + arg.name}</a>
199-
: ("--" + arg.name)}
193+
? <a href={docsLink}>{"--" + arg.long}</a>
194+
: ("--" + arg.long)}
200195
</code>{" "}
201196
<HeaderAnchor id={id} />
202197
</h3>

0 commit comments

Comments
 (0)