CLI: Fix bug in doc generator (#3153)
This commit is contained in:
parent
589c2e53b7
commit
7c8874d930
File diff suppressed because it is too large
Load Diff
|
@ -17,10 +17,14 @@ import * as submit from "./cmds/submit";
|
||||||
import * as sui from "./cmds/sui";
|
import * as sui from "./cmds/sui";
|
||||||
import * as verifyVaa from "./cmds/verifyVaa";
|
import * as verifyVaa from "./cmds/verifyVaa";
|
||||||
|
|
||||||
|
|
||||||
const MD_TAG = "<!--CLI_USAGE-->";
|
const MD_TAG = "<!--CLI_USAGE-->";
|
||||||
|
|
||||||
async function getHelpText(name: string, cmd: any): Promise<string> {
|
async function getHelpText(cmd: any): Promise<string> {
|
||||||
return await cmd.builder(yargs).scriptName(`worm ${cmd.command}`).getHelp();
|
// Note that `yargs` is called as a function to produce a fresh copy.
|
||||||
|
// Otherwise the imported module is effectively a singleton where state from
|
||||||
|
// other commands is accumulated from repeat calls.
|
||||||
|
return await cmd.builder(yargs()).scriptName(`worm ${cmd.command}`).getHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
(async function () {
|
(async function () {
|
||||||
|
@ -39,8 +43,8 @@ async function getHelpText(name: string, cmd: any): Promise<string> {
|
||||||
];
|
];
|
||||||
|
|
||||||
const helpOutputs: Buffer[] = [];
|
const helpOutputs: Buffer[] = [];
|
||||||
for (const [name, cmd] of Object.entries(cmds)) {
|
for (const cmd of cmds) {
|
||||||
const helpText = await getHelpText(name, cmd);
|
const helpText = await getHelpText(cmd);
|
||||||
|
|
||||||
helpOutputs.push(Buffer.from(`
|
helpOutputs.push(Buffer.from(`
|
||||||
<details>
|
<details>
|
||||||
|
|
|
@ -18,6 +18,8 @@ import * as sui from "./cmds/sui";
|
||||||
import * as transfer from "./cmds/transfer";
|
import * as transfer from "./cmds/transfer";
|
||||||
import * as verifyVaa from "./cmds/verifyVaa";
|
import * as verifyVaa from "./cmds/verifyVaa";
|
||||||
|
|
||||||
|
// Note: When adding another subcommand here, please be sure to also include it
|
||||||
|
// in the `cmds` array in `docs.ts` so it is properly documented.
|
||||||
yargs(hideBin(process.argv))
|
yargs(hideBin(process.argv))
|
||||||
// https://github.com/yargs/yargs/blob/main/docs/advanced.md#commanddirdirectory-opts
|
// https://github.com/yargs/yargs/blob/main/docs/advanced.md#commanddirdirectory-opts
|
||||||
// can't use `.commandDir` because bundling + tree-shaking
|
// can't use `.commandDir` because bundling + tree-shaking
|
||||||
|
|
Loading…
Reference in New Issue