diff options
author | Akshay <[email protected]> | 2020-07-15 16:09:46 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2020-07-15 16:09:46 +0100 |
commit | 859ac5d3e49bc9a123df3f5a74b43d2281a3bed1 (patch) | |
tree | 7f5f49ec0b75bff5917b093fefc6e34746909eaf /src/utils.rs | |
parent | 99d2a835b4f032de78d9cdbe27521363a25204bd (diff) |
add utils for auto habits
auto trackable habits can be added, but not tracked as of this commit
Diffstat (limited to 'src/utils.rs')
-rw-r--r-- | src/utils.rs | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/utils.rs b/src/utils.rs index 1d56377..e6ec6ac 100644 --- a/src/utils.rs +++ b/src/utils.rs | |||
@@ -34,13 +34,23 @@ pub fn load_configuration_file() -> AppConfig { | |||
34 | }; | 34 | }; |
35 | } | 35 | } |
36 | 36 | ||
37 | pub fn data_file() -> PathBuf { | 37 | fn project_dirs() -> ProjectDirs { |
38 | if let Some(proj_dirs) = ProjectDirs::from("rs", "nerdypepper", "dijo") { | 38 | ProjectDirs::from("rs", "nerdypepper", "dijo") |
39 | let mut data_file = PathBuf::from(proj_dirs.data_dir()); | 39 | .unwrap_or_else(|| panic!("Invalid home directory!")) |
40 | fs::create_dir_all(&data_file); | 40 | } |
41 | data_file.push("habit_record.json"); | 41 | |
42 | return data_file; | 42 | pub fn habit_file() -> PathBuf { |
43 | } else { | 43 | let proj_dirs = project_dirs(); |
44 | panic!("Invalid home directory!") | 44 | let mut data_file = PathBuf::from(proj_dirs.data_dir()); |
45 | }; | 45 | fs::create_dir_all(&data_file); |
46 | data_file.push("habit_record.json"); | ||
47 | return data_file; | ||
48 | } | ||
49 | |||
50 | pub fn auto_habit_file() -> PathBuf { | ||
51 | let proj_dirs = project_dirs(); | ||
52 | let mut data_file = PathBuf::from(proj_dirs.data_dir()); | ||
53 | fs::create_dir_all(&data_file); | ||
54 | data_file.push("habit_record[auto].json"); | ||
55 | return data_file; | ||
46 | } | 56 | } |