diff options
Diffstat (limited to 'src/utils.rs')
-rw-r--r-- | src/utils.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/utils.rs b/src/utils.rs index 55900b0..ab7e7ef 100644 --- a/src/utils.rs +++ b/src/utils.rs | |||
@@ -1,4 +1,6 @@ | |||
1 | use cursive::theme::{BaseColor, Color}; | 1 | use cursive::theme::{BaseColor, Color}; |
2 | use directories::ProjectDirs; | ||
3 | use std::path::{Path, PathBuf}; | ||
2 | 4 | ||
3 | pub struct AppConfig { | 5 | pub struct AppConfig { |
4 | pub true_chr: char, | 6 | pub true_chr: char, |
@@ -30,3 +32,13 @@ pub fn load_configuration_file() -> AppConfig { | |||
30 | future_color: Color::Light(BaseColor::Black), | 32 | future_color: Color::Light(BaseColor::Black), |
31 | }; | 33 | }; |
32 | } | 34 | } |
35 | |||
36 | pub fn data_file() -> PathBuf { | ||
37 | if let Some(proj_dirs) = ProjectDirs::from("rs", "nerdypepper", "dijo") { | ||
38 | let mut data_file = PathBuf::from(proj_dirs.data_dir()); | ||
39 | data_file.push("habit_record.json"); | ||
40 | return data_file; | ||
41 | } else { | ||
42 | panic!("Invalid home directory!") | ||
43 | }; | ||
44 | } | ||