aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs11
-rw-r--r--src/paths.rs6
2 files changed, 15 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index bd9bc07..fbb078b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,11 +1,18 @@
mod checks;
mod display;
+mod paths;
mod views;
mod ynab;
+use std::io::Read;
+
fn main() {
- let key = std::env::args().nth(1).unwrap();
- let client = ynab::Client::new(&key);
+ let mut key = String::new();
+ std::fs::File::open(paths::api_key())
+ .unwrap()
+ .read_to_string(&mut key)
+ .unwrap();
+ let client = ynab::Client::new(&key.trim());
let budget = client.default_budget();
checks::run_checks(&budget);
diff --git a/src/paths.rs b/src/paths.rs
new file mode 100644
index 0000000..31c07d0
--- /dev/null
+++ b/src/paths.rs
@@ -0,0 +1,6 @@
+pub fn api_key() -> std::path::PathBuf {
+ directories::ProjectDirs::from("", "", "ynab")
+ .unwrap()
+ .config_dir()
+ .join("api-key")
+}