Class SessionStore
java.lang.Object
com.shaft.commandline.session.SessionStore
Persists the current
SessionInfo as JSON at <baseDir>/cli-session.json.-
Constructor Summary
ConstructorsConstructorDescriptionCreates a store rooted at<user.home>/.shaft.SessionStore(Path baseDir) Creates a store rooted at the given directory, for tests. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Deletes the session file if present.load()Loads the persisted session, tolerating a missing or corrupt file.path()voidsave(SessionInfo info) Persists the session, writing atomically via a temp file plus move-replace.
-
Constructor Details
-
SessionStore
public SessionStore()Creates a store rooted at<user.home>/.shaft. -
SessionStore
Creates a store rooted at the given directory, for tests.- Parameters:
baseDir- the directory the session file lives in
-
-
Method Details
-
path
- Returns:
- the path to the session file, whether or not it currently exists
-
load
Loads the persisted session, tolerating a missing or corrupt file.- Returns:
- the persisted session, or empty if none is stored or it cannot be parsed
-
save
Persists the session, writing atomically via a temp file plus move-replace.- Parameters:
info- the session to persist
-
clear
public void clear()Deletes the session file if present.
-