CLI: Fix bug in doc generator (#3153)

This commit is contained in:
Ben Guidarelli 2023-06-29 14:21:38 -04:00 committed by GitHub
parent 589c2e53b7
commit 7c8874d930
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 83 additions and 835 deletions

File diff suppressed because it is too large Load Diff

View File

@ -17,10 +17,14 @@ import * as submit from "./cmds/submit";
import * as sui from "./cmds/sui";
import * as verifyVaa from "./cmds/verifyVaa";
const MD_TAG = "<!--CLI_USAGE-->";
async function getHelpText(name: string, cmd: any): Promise<string> {
return await cmd.builder(yargs).scriptName(`worm ${cmd.command}`).getHelp();
async function getHelpText(cmd: any): Promise<string> {
// 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 () {
@ -39,8 +43,8 @@ async function getHelpText(name: string, cmd: any): Promise<string> {
];
const helpOutputs: Buffer[] = [];
for (const [name, cmd] of Object.entries(cmds)) {
const helpText = await getHelpText(name, cmd);
for (const cmd of cmds) {
const helpText = await getHelpText(cmd);
helpOutputs.push(Buffer.from(`
<details>

View File

@ -18,6 +18,8 @@ import * as sui from "./cmds/sui";
import * as transfer from "./cmds/transfer";
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))
// https://github.com/yargs/yargs/blob/main/docs/advanced.md#commanddirdirectory-opts
// can't use `.commandDir` because bundling + tree-shaking