Expand description
The game session: what every shellgame command does.
Session ports GameSession, ProgressTracker and NavigationManager of the Python
version. It is the one place that combines the pieces: the Catalog says what the levels
are, StateStore what the player has done, the engine judges work and prepares workspaces,
screens shows the result, and Directives asks the wrapping shell to move or to
export variables. The CLI layer (crate::cli) only parses arguments and calls one method.
| command | method |
|---|---|
| (none) | Session::show_current_level |
hint [-r] | Session::hint |
submit [ANSWER...] | Session::submit |
status, skip, reset | Session::status, Session::skip, Session::reset |
repeat, show | Session::repeat, Session::show |
remove, exit, init | Session::remove, Session::exit, Session::init |
dev ... | Session::dev_jump, Session::dev_next, Session::dev_prev, Session::dev_reload, Session::dev_start |
update | Session::update |
cd-hook ..., fd-hook | Session::cd_pre, Session::cd_post, Session::legacy_cd_pre, Session::legacy_cd_post, Session::fd_hook |
Every method returns the process exit status: OK when the command did what the player
asked (a wrong answer is a normal outcome), FAILURE when it could not, USAGE for a
usage error and, for cd-hook pre, BLOCKED.
§Where the player is
The session keeps the player’s directory in memory and updates it whenever it asks the shell to
cd, as Python’s os.chdir did, so a second check in the same run neither repeats the
directive nor shows the teleport notice twice. When a level was prepared in this run while the
player stands below its section directory, that directory may have been deleted and recreated
underneath the shell, so the next teleport check asks the shell to cd even when the path is
unchanged (without a notice).
§Directives before prompts
The environment exports and the teleport of a level are emitted before the Enter prompts that may follow, so the wrapper applies them even when the player presses Ctrl-C at a prompt (the prompt ends like Enter, the process exits normally, the wrapper replays what was emitted).
Modules§
- update
shellgame update: downloads the release archive for this platform, checks that the new binary runs and replaces the running one.
Structs§
- Session
- One run of the game: the environment, the catalog, the state store and the output.
Enums§
- Failure
- Why a command could not do its job, as opposed to the player getting something wrong. Shown as
a red panel; the exit status is
FAILURE.
Constants§
- BLOCKED
- Exit status of
cd-hook prewhen the level forbids the move. - FAILURE
- Exit status of a command that could not do what was asked: no game, an unknown level, a
filesystem or state error, a declined
remove. - OK
- Exit status of a command that did what the player asked, wrong answers included.
- USAGE
- Exit status of a usage error.
Functions§
- cd_
target - The directory a
cdcall names: its first non-option argument.