// SPDX-FileCopyrightText: 2026 Terin Stock // SPDX-License-Identifier: EUPL-1.2 package main import ( "flag" "fmt" "os" humanize "github.com/dustin/go-humanize" "go.terinstock.com/odescsitoolbox/toolbox" ) func listCDs(d *toolbox.Device) { fileEntries, err := d.ListCDs() if err != nil { fmt.Printf("unable to fetch CD list: %v\n", err) os.Exit(1) } fmt.Printf("index,name,size\n") for _, entry := range fileEntries { fmt.Printf("%d,%s,%s\n", entry.Index(), entry.Name(), humanize.IBytes(entry.Size())) } } func setCD(d *toolbox.Device, idx int) { err := d.SetCDByIndex(idx) if err != nil { fmt.Printf("unable to set CD index: %v\n", err) os.Exit(1) } } func main() { device := flag.String("dev", "/dev/sr0", "the ODE device") index := flag.Int("index", -1, "the index to set") flag.Parse() d, err := toolbox.Open(*device) if err != nil { fmt.Printf("unable to open device: %v\n", err) os.Exit(1) } defer d.Close() if *index >= 0 { setCD(d, *index) } else { listCDs(d) } }