22import { z } from " astro:schema" ;
33import { experimental_getWranglerCommands } from " wrangler" ;
44import AnchorHeading from " ./AnchorHeading.astro" ;
5- import Type from " ./Type.astro" ;
65import { PackageManagers } from " starlight-package-managers" ;
7- import MetaInfo from " ./MetaInfo.astro" ;
6+ import WranglerArg from " ./WranglerArg.astro" ;
7+ import Details from " ./Details.astro" ;
88
99function getCommand(path : string ) {
1010 const segments = path .trim ().split (/ \s + / );
@@ -41,10 +41,6 @@ if (!definition.args) {
4141
4242const { globalFlags } = experimental_getWranglerCommands ();
4343
44- const args = Object .entries (definition .args ).concat (
45- Object .entries (globalFlags as unknown as typeof definition .args ),
46- );
47-
4844const positionals = definition .positionalArgs
4945 ?.map ((p ) => ` [${p .toUpperCase ()}] ` )
5046 .join (" " );
@@ -60,37 +56,20 @@ const positionals = definition.positionalArgs
6056
6157<ul >
6258 {
63- args
64- .filter (([_ , value ]) => ! value .hidden && value . type !== undefined )
59+ Object . entries ( definition . args )
60+ .filter (([_ , value ]) => ! value .hidden )
6561 .map (([key , value ]) => {
66- const description = value .description ?? value .describe ;
67- const required = value .demandOption ;
68- const defaultValue = value .default ;
69- const alias = value .alias ;
70- const positional = definition .positionalArgs ?.includes (key );
71-
72- const name = positional ? ` [${key .toUpperCase ()}] ` : ` --${key } ` ;
73-
74- let aliasText;
75- if (alias ) {
76- if (Array .isArray (alias )) {
77- aliasText = ` aliases: --${alias .join (" , --" )} ` ;
78- } else {
79- aliasText = ` alias: --${alias } ` ;
80- }
81- }
82-
83- return (
84- <li >
85- <code >{ name } </code > <Type text = { value .type } />{ " " }
86- { aliasText && <MetaInfo text = { aliasText } />}
87- { required && <MetaInfo text = " required" />}
88- { defaultValue !== undefined && (
89- <MetaInfo text = { ` default: ${defaultValue } ` } />
90- )}
91- <p >{ description } </p >
92- </li >
93- );
62+ return <WranglerArg key = { key } definition = { value } />;
9463 })
9564 }
9665</ul >
66+
67+ <Details header =" Global flags" >
68+ <ul >
69+ {
70+ Object .entries (globalFlags ).map (([key , value ]) => {
71+ return <WranglerArg key = { key } definition = { value } />;
72+ })
73+ }
74+ </ul >
75+ </Details >
0 commit comments