diff --git a/README.md b/README.md index d9b2bbc..0461237 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ netbsd-up --cpu host --memory 4G --cpus 4 netbsd-up --output netbsd-10.1.iso # Use existing disk image -netbsd-up --drive vm-disk.img --disk-format qcow2 +netbsd-up --image vm-disk.img --disk-format qcow2 ``` ## 🛠️ Command Line Options @@ -149,7 +149,7 @@ netbsd-up --drive vm-disk.img --disk-format qcow2 | `--cpu` | `-c` | CPU type to emulate | `host` | | `--cpus` | `-C` | Number of CPU cores | `2` | | `--memory` | `-m` | Amount of VM memory | `2G` | -| `--drive` | `-d` | Path to VM disk image | None | +| `--image` | `-i` | Path to VM disk image | None | | `--disk-format` | | Disk image format | `raw` | | `--size` | `-s` | Size of the disk image to create if it doesn't exist | `20G` | | `--bridge` | `-b` | Name of the network bridge to use for networking (e.g., br0) | None | @@ -187,7 +187,7 @@ netbsd-up --cpus 8 --memory 8G --cpu host qemu-img create -f qcow2 netbsd-dev.qcow2 20G # Start VM with the disk -./main.ts --drive netbsd-dev.qcow2 --disk-format qcow2 +./main.ts --image netbsd-dev.qcow2 --disk-format qcow2 ``` ### 🔢 Specific versions diff --git a/main.ts b/main.ts index 1f233aa..0c10bd1 100755 --- a/main.ts +++ b/main.ts @@ -36,7 +36,7 @@ if (import.meta.main) { .option("-m, --memory ", "Amount of memory for the VM", { default: "2G", }) - .option("-d, --drive ", "Path to VM disk image") + .option("-i, --image ", "Path to VM disk image") .option( "--disk-format ", "Disk image format (e.g., qcow2, raw)", @@ -106,11 +106,11 @@ if (import.meta.main) { isoPath = await downloadIso(resolvedInput, options); } - if (options.drive) { + if (options.image) { await createDriveImageIfNeeded(options); } - if (!input && options.drive && !await emptyDiskImage(options.drive)) { + if (!input && options.image && !await emptyDiskImage(options.image)) { isoPath = null; } diff --git a/src/utils.ts b/src/utils.ts index a88924c..7e1e7d0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -12,7 +12,7 @@ export interface Options { cpu: string; cpus: number; memory: string; - drive?: string; + image?: string; diskFormat: string; size: string; bridge?: string; @@ -47,12 +47,12 @@ export async function downloadIso( const filename = url.split("/").pop()!; const outputPath = options.output ?? filename; - if (options.drive && await Deno.stat(options.drive).catch(() => false)) { - const driveSize = await du(options.drive); + if (options.image && await Deno.stat(options.image).catch(() => false)) { + const driveSize = await du(options.image); if (driveSize > 10) { console.log( chalk.yellowBright( - `Drive image ${options.drive} is not empty (size: ${driveSize} KB), skipping ISO download to avoid overwriting existing data.`, + `Drive image ${options.image} is not empty (size: ${driveSize} KB), skipping ISO download to avoid overwriting existing data.`, ), ); return null; @@ -174,9 +174,9 @@ export async function runQemu( "chardev:con0", ...await setupFirmwareFilesIfNeeded(), ..._.compact( - options.drive && [ + options.image && [ "-drive", - `file=${options.drive},format=${options.diskFormat},if=virtio`, + `file=${options.image},format=${options.diskFormat},if=virtio`, ], ), "-object", @@ -200,7 +200,7 @@ export async function runQemu( diskSize: options.size, diskFormat: options.diskFormat, isoPath: isoPath ? Deno.realPathSync(isoPath) : undefined, - drivePath: options.drive ? Deno.realPathSync(options.drive) : undefined, + drivePath: options.image ? Deno.realPathSync(options.image) : undefined, version: DEFAULT_VERSION, status: "RUNNING", pid: cmd.pid, @@ -237,7 +237,7 @@ export function handleInput(input?: string): string { export async function createDriveImageIfNeeded( { - drive: path, + image: path, diskFormat: format, size, }: Options,