tmountain / uchess

♛♔ Play chess against UCI engines in your terminal.
MIT License
64 stars 7 forks source link

fix: implement quit command fixes #9 #10

Open jfkw opened 1 year ago

jfkw commented 1 year ago

The quit command is not implemented although it is documented. cmd/uchess does handle Ctrl-C to exit currently.

Add a pkg/cmd ProcessCmd() case handler for the command "quit". Add a private function pkg/cmd quit() where additional game state shutdown housekeeping could be processed, e.g. autosave on quit if desired. Currenly the function only returns the msg "quit", mirroring the hint command.

Add a cmd/uchess Interact() handler for the msg "quit". On quit, ask for confirmation with Y or y. Exit process on confirm, without saving as is currently documented. Move the internal function Interact().quit() to a public function cmd/uchess Quit() where additional process shutdown housekeeping could be implemented. Currently the function only calls gamestate S.Fini() and os.Exit(0) the process with return code.