func main() { flag.Usage = usage flag.Parse() pf := strings.Split(*pakFiles, ",") p, err := pak.MultiOpen(pf...) if err != nil { log.Fatalf("Opening pakfiles %q: %v", pf, err) } defer p.Close() if flag.NArg() == 0 { usage() log.Fatalf("Need to specify a command.") } cmd := flag.Arg(0) args := flag.Args()[1:] switch cmd { case "convert": convert(p, args...) case "pov": triangles(p, args...) case "info": info(p, args...) default: log.Fatalf("Unknown command %q", cmd) } }
func main() { flag.Usage = usage flag.Parse() if flag.NArg() < 2 { usage() os.Exit(1) } pakFiles := strings.Split(flag.Arg(0), ",") p, err := pak.MultiOpen(pakFiles...) if err != nil { log.Fatal(err) } defer p.Close() switch flag.Arg(1) { case "list": for _, k := range p.List() { fmt.Printf("%s\n", k) } case "extract": fn := flag.Arg(2) of, err := os.Create(fn) if err != nil { log.Fatalf("Opening output file %q: %v", fn, err) } defer of.Close() handle, err := p.Get(fn) if err != nil { log.Fatalf("Getting %q: %v", fn, err) } if _, err := io.Copy(of, handle); err != nil { os.Remove(of.Name()) log.Fatalf("Failed to extract %q: %v", fn, err) } default: log.Fatalf("Unknown command %q", flag.Arg(1)) } }
func main() { flag.Usage = usage flag.Parse() if *cpuprofile != "" { f, err := os.Create(*cpuprofile) if err != nil { log.Fatal(err) } pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() } pf := strings.Split(*pakFiles, ",") p, err := pak.MultiOpen(pf...) if err != nil { log.Fatalf("Opening pakfiles %q: %v", pf, err) } defer p.Close() if flag.NArg() == 0 { usage() log.Fatalf("Need to specify a command.") } cmd := flag.Arg(0) args := flag.Args()[1:] switch cmd { case "convert": convert(p, args...) case "info": info(p, args...) default: log.Fatalf("Unknown command %q", cmd) } }