import type { ResolvedPingTarget } from "./types";

export function buildPingCommand(t: ResolvedPingTarget, platform: NodeJS.Platform = process.platform): string[] {
  if (platform === "win32") {
    return [
      "ping",
      "-n",
      String(t.icmp.count),
      "-l",
      String(t.icmp.packetSize),
      "-w",
      String(t.timeoutMs),
      t.icmp.host,
    ];
  }
  const timeout = platform === "linux" ? String(Math.ceil(t.timeoutMs / 1000)) : String(t.timeoutMs);
  return ["ping", "-c", String(t.icmp.count), "-s", String(t.icmp.packetSize), "-W", timeout, t.icmp.host];
}
