From 426bcffb2cd6f7b1e8ff95b5e0772e48ba28988f Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 27 Aug 2019 01:17:59 -0400 Subject: add a command to dump the schema too --- CHANGELOG.md | 5 +++++ Cargo.toml | 2 +- README.md | 3 ++- src/main.rs | 7 +++++++ 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG.md 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 "] 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 { -- cgit v1.2.3-54-g00ecf