-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change: move previous attempt to session file
...rather than getting last modified folder. This makes it more reliable and make more sense especially when using a custom attempts folder.
- Loading branch information
1 parent
8948360
commit ffcc3ce
Showing
4 changed files
with
38 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,25 @@ | ||
use std::{ | ||
fs::File, | ||
io::BufReader, | ||
path::{Path, PathBuf}, | ||
}; | ||
|
||
use anyhow::Context; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct Session { | ||
pub last_template: String, | ||
pub previous_attempt: PathBuf, | ||
} | ||
|
||
impl Session { | ||
pub fn from_file(path: &Path) -> anyhow::Result<Self> { | ||
let file = File::open(path) | ||
.context("Could not open session file, have you run atmpt recently?")?; | ||
let session: Self = serde_json::from_reader(BufReader::new(file)) | ||
.context("Failed to read session file!")?; | ||
|
||
Ok(session) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters