Download src/cli/program/action-reparse.ts from shimen/shinclaw: direct link, hf CLI and curl.
- Browser
- Download file 761 Bytes
-
https://huggingface.co/spaces/shimen/shinclaw/resolve/main/src/cli/program/action-reparse.ts
- Command line
-
hf download hf://spaces/shimen/shinclaw/src/cli/program/action-reparse.ts
-
curl -L -o action-reparse.ts https://huggingface.co/spaces/shimen/shinclaw/resolve/main/src/cli/program/action-reparse.ts
761 Bytes
| import type { Command } from "commander"; | |
| import { buildParseArgv } from "../argv.js"; | |
| import { resolveActionArgs } from "./helpers.js"; | |
| export async function reparseProgramFromActionArgs( | |
| program: Command, | |
| actionArgs: unknown[], | |
| ): Promise<void> { | |
| const actionCommand = actionArgs.at(-1) as Command | undefined; | |
| const root = actionCommand?.parent ?? program; | |
| const rawArgs = (root as Command & { rawArgs?: string[] }).rawArgs; | |
| const actionArgsList = resolveActionArgs(actionCommand); | |
| const fallbackArgv = actionCommand?.name() | |
| ? [actionCommand.name(), ...actionArgsList] | |
| : actionArgsList; | |
| const parseArgv = buildParseArgv({ | |
| programName: program.name(), | |
| rawArgs, | |
| fallbackArgv, | |
| }); | |
| await program.parseAsync(parseArgv); | |
| } | |