Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement interactive command quit #9

Open
jfkw opened this issue Mar 30, 2023 · 0 comments
Open

Implement interactive command quit #9

jfkw opened this issue Mar 30, 2023 · 0 comments

Comments

@jfkw
Copy link

jfkw commented Mar 30, 2023

Interactive command quit is documented in README. However, there is no case handler for quit in pkg/cmd func ProcessCmd().

The interactive tcell loop in cmd/uchess func Interact() handles Ctrl-C, so there is currently a way to quit the app.

When implementing, avoid coupling pkg/cmd and cmd/uchess such that they both handle process quit concerns with overlap. The goal should be for pkg/cmd to handle game state shutdown, and cmd/uchess to handle process shutdown.

jfkw added a commit to jfkw/uchess that referenced this issue Mar 30, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant