File size: 1,012 Bytes
34810d2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | // Normalized argv invocation summary used before Commander command dispatch.
import {
getCommandPathWithRootOptions,
getPrimaryCommand,
isHelpOrVersionInvocation,
isRootHelpInvocation,
} from "./argv.js";
import { resolveGatewayCatalogCommandPath } from "./gateway-run-argv.js";
import { resolveCliParentCommandPath } from "./parent-command-path.js";
type CliArgvInvocation = {
argv: string[];
commandPath: string[];
primary: string | null;
hasHelpOrVersion: boolean;
isRootHelpInvocation: boolean;
};
/** Resolves command path and help/version mode from a raw process argv array. */
export function resolveCliArgvInvocation(argv: string[]): CliArgvInvocation {
return {
argv,
commandPath:
resolveGatewayCatalogCommandPath(argv) ??
resolveCliParentCommandPath(argv) ??
getCommandPathWithRootOptions(argv, 2),
primary: getPrimaryCommand(argv),
hasHelpOrVersion: isHelpOrVersionInvocation(argv),
isRootHelpInvocation: isRootHelpInvocation(argv),
};
}
|