func main() { identity := flag.String("identity", "", "ssh key to use to start server") addr := flag.String("address", "0.0.0.0:4273", "address to listen on for ssh connections") ws := flag.Bool("ws", false, "start the web socket server on addr") flag.Parse() if len(flag.Args()) < 1 { fmt.Println("Please provide a game") return } story := flag.Args()[0] buf, err := ioutil.ReadFile(story) if err != nil { panic(err) } mem := gork.NewZMemory(buf) header, err := gork.NewZHeader(mem) if err != nil { panic(err) } if *identity != "" { server := &SshServer{ id_rsa: *identity, story: story, mem: mem, header: header, } server.run(*addr) } else if *ws { server := &WSServer{ story: story, mem: mem, header: header, } server.run(*addr) } else { terminalUI(story, mem, header) } }
func dumpStoryInfo(story string, conf *config) { buf, err := ioutil.ReadFile(story) if err != nil { fmt.Println("\nUnable to open story", story, "Error:", err) return } mem := gork.NewZMemory(buf) fmt.Println("\nStory file is", story) header, err := gork.NewZHeader(mem) if err != nil { panic(err) } if conf.showHeader { fmt.Println(header) } if conf.showObjects { DumpAllZObjects(mem, header) } if conf.showObjectTree { DumpZObjectsTree(mem, header) } if conf.showAbbreviations { DumpAbbreviations(mem, header) } if conf.showDictionary { fmt.Println(gork.NewZDictionary(mem, header)) } fmt.Println("") }