aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-08-27 01:17:59 -0400
committerJesse Luehrs <doy@tozt.net>2019-08-27 01:17:59 -0400
commit426bcffb2cd6f7b1e8ff95b5e0772e48ba28988f (patch)
treeaeaddf57b9f6bb406d4a312310f677b5c6f0477d
parentd8b6975f3648bef228060f71480c86cc2d9cd540 (diff)
downloadynab-export-426bcffb2cd6f7b1e8ff95b5e0772e48ba28988f.tar.gz
ynab-export-426bcffb2cd6f7b1e8ff95b5e0772e48ba28988f.zip
add a command to dump the schema too
-rw-r--r--CHANGELOG.md5
-rw-r--r--Cargo.toml2
-rw-r--r--README.md3
-rw-r--r--src/main.rs7
4 files changed, 15 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..551fba9
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,5 @@
+* 0.0.2 2019-08-27
+ * add `ynab-export schema`
+
+* 0.0.1 2019-08-27
+ * initial release
diff --git a/Cargo.toml b/Cargo.toml
index 255dd70..4b7fe01 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ynab-export"
-version = "0.0.1"
+version = "0.0.2"
authors = ["Jesse Luehrs <doy@tozt.net>"]
edition = "2018"
description = "ynab-export is a tool to help export a YNAB budget to a database"
diff --git a/README.md b/README.md
index a3c5c8b..a9ac200 100644
--- a/README.md
+++ b/README.md
@@ -6,8 +6,9 @@ file that can be used to represent this data.
## Example
+ ynab-export schema | psql ynab
+
ynab-export
- psql ynab < data/schema.sql
psql ynab -c 'COPY accounts FROM STDIN' < accounts.tsv
psql ynab -c 'COPY category_groups FROM STDIN' < category_groups.tsv
psql ynab -c 'COPY categories FROM STDIN' < categories.tsv
diff --git a/src/main.rs b/src/main.rs
index 218cf46..965467a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,6 +4,8 @@ const PROJECT_NAME: &str = "ynab";
// XXX is this fixed? or is it specific to my account?
const SPLIT_CATEGORY_ID: &str = "4f42d139-ded2-4782-b16e-e944868fbf62";
+const SCHEMA: &str = include_str!("../data/schema.sql");
+
pub fn api_key() -> std::path::PathBuf {
directories::ProjectDirs::from("", "", PROJECT_NAME)
.unwrap()
@@ -24,6 +26,11 @@ pub fn read_api_key() -> String {
#[allow(clippy::cognitive_complexity)]
fn main() {
+ if std::env::args().nth(1) == Some("schema".to_string()) {
+ print!("{}", SCHEMA);
+ std::process::exit(0);
+ }
+
let key = read_api_key();
let mut ynab_config = ynab_api::apis::configuration::Configuration::new();
ynab_config.api_key = Some(ynab_api::apis::configuration::ApiKey {