package main /* * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return * ---------------------------------------------------------------------------- */ import ( "flag" "fmt" "os" ) func errorHandler(e error) { if e != nil { panic(e) } } func main() { wipeCmd := flag.NewFlagSet("wipe", flag.ExitOnError) wipeDod := wipeCmd.Bool("dod", false, "enable") wipeBs := wipeCmd.Int("bs", 1024, "block size") cloneCmd := flag.NewFlagSet("clone", flag.ExitOnError) cloneBs := cloneCmd.Int("bs", 1024, "block size") if len(os.Args) < 2 { fmt.Println("Expected 'wipe' or 'clone' subcommands") os.Exit(1) } switch os.Args[1] { case "wipe": wipeCmd.Parse(os.Args[2:]) if len(wipeCmd.Args()) > 1 { fmt.Println("Only one volume to wipe is supported") os.Exit(1) } wipeDisk := wipeCmd.Args()[0] wipe(*wipeDod, *wipeBs, wipeDisk) case "clone": cloneCmd.Parse(os.Args[2:]) if len(cloneCmd.Args()) > 2 { fmt.Println("Only one input and one output volume is supported") os.Exit(1) } cloneSource := cloneCmd.Args()[0] cloneTarget := cloneCmd.Args()[1] clone(*cloneBs, cloneSource, cloneTarget) default: fmt.Println("Expected 'wipe' or 'clone' subcommands") os.Exit(1) } }