2026-10-11 23:34:02 -04:00
|
|
|
import { z } from "incur";
|
|
|
|
|
import { createGoBinaryService } from "../composition/go.js";
|
|
|
|
|
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
|
|
|
|
import { logCliCommand } from "../cliLogging.js";
|
|
|
|
|
import type { Logger } from "pino";
|
|
|
|
|
import type { CliInstance } from "./types.js";
|
|
|
|
|
import { withCommandCancellation } from "./commandCancellation.js";
|
2026-10-13 16:08:41 +08:00
|
|
|
import { finishAnalysisCommand } from "./finishAnalysisCommand.js";
|
2026-10-15 05:19:43 -07:00
|
|
|
import { absoluteCallerPath } from "../filesystem/callerPath.js";
|
2026-10-11 23:34:02 -04:00
|
|
|
|
|
|
|
|
/** Resolve caller paths and inspect static build metadata through the shared workflow. */
|
|
|
|
|
export const registerGoCommands = (cli: CliInstance, logger: Logger): void => {
|
|
|
|
|
cli.command(CLI_COMMANDS.inspectGoBinary, {
|
|
|
|
|
description:
|
|
|
|
|
"Inspect embedded Go compiler, modules and build settings without target execution",
|
|
|
|
|
args: z.object({
|
|
|
|
|
path: z.string().describe("Local ELF, PE or thin Mach-O image"),
|
|
|
|
|
}),
|
|
|
|
|
run: ({ args }) =>
|
2026-10-13 16:08:41 +08:00
|
|
|
withCommandCancellation(async (signal) => {
|
|
|
|
|
const service = createGoBinaryService();
|
|
|
|
|
return await logCliCommand(
|
|
|
|
|
logger,
|
|
|
|
|
CLI_COMMANDS.inspectGoBinary,
|
|
|
|
|
async () =>
|
|
|
|
|
finishAnalysisCommand(
|
2026-10-15 05:19:43 -07:00
|
|
|
() =>
|
|
|
|
|
service.inspect(
|
|
|
|
|
{ path: absoluteCallerPath(args.path) },
|
|
|
|
|
{ signal },
|
|
|
|
|
),
|
2026-10-13 16:08:41 +08:00
|
|
|
service,
|
|
|
|
|
"go-build-info",
|
|
|
|
|
"inspect_go_binary",
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}),
|
2026-10-11 23:34:02 -04:00
|
|
|
});
|
|
|
|
|
};
|