From 60ace9e35f9e4acfb6919f6ca4deebe70aa76d84 Mon Sep 17 00:00:00 2001 From: 35V LG84 <35vlg84-x4e6b92@e257.fi> Date: Mon, 23 Dec 2024 21:51:59 +0200 Subject: [PATCH] Add support for new storage keys * `input.fs.path` * `input.git.repo` Signed-off-by: 35V LG84 <35vlg84-x4e6b92@e257.fi> --- CHANGELOG.adoc | 4 +++- README.adoc | 2 +- examples/audit.toml | 2 +- examples/simple.toml | 4 ++-- examples/simple/{ => txns}/journal.txn | 0 examples/tackler.toml | 14 +++++++------- perf/bin/perf-all.sh | 1 + perf/perf.toml | 4 ++-- suite | 2 +- tackler-cli/CRATES.md | 10 +++++++--- tackler-core/src/config/items.rs | 18 ++++++++++++++++-- tackler-core/src/config/raw_items.rs | 8 ++++++-- 12 files changed, 47 insertions(+), 22 deletions(-) rename examples/simple/{ => txns}/journal.txn (100%) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 30417ee..b3883e2 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -32,7 +32,9 @@ tackler-core = "0.6.0" New features: * Git Backend: Add support for `revspecs` with `--input.git.ref` - +* Add support for new storage keys + ** `input.fs.path`, path to top level fs-storage location + ** `input.git.repo`, alias for `input.git.repository` ==== Fixes diff --git a/README.adoc b/README.adoc index 2334169..25b2931 100644 --- a/README.adoc +++ b/README.adoc @@ -11,7 +11,7 @@ link:https://tackler.e257.fi/[Tackler] is fast, reliable bookkeeping engine with native GIT SCM support for plain text accounting, written in Rust. ```bash -~/tackler-ng $ cat example/simle/journal.txn +~/tackler-ng $ cat examples/simple/txns/journal.txn 2024-12-01 'Sweet'n Sour Candies Expenses:Sweets:Candy 2.50 diff --git a/examples/audit.toml b/examples/audit.toml index 9b46ebd..21ed6f6 100644 --- a/examples/audit.toml +++ b/examples/audit.toml @@ -12,7 +12,7 @@ strict = true audit = { mode = true, hash = "SHA-256" } timestamp = { default-time = 00:00:00, timezone = { name = "UTC" } } -input = { storage = "git", git = { repository = "../suite/audit/audit-repo.git", dir = "txns", ref = "txns-1E1", suffix = "txn" } } +input = { storage = "git", git = { repo = "../suite/audit/audit-repo.git", dir = "txns", ref = "txns-1E1", suffix = "txn" } } [transaction] accounts = { path = "audit/accounts.toml" } diff --git a/examples/simple.toml b/examples/simple.toml index 4528178..7c7d897 100644 --- a/examples/simple.toml +++ b/examples/simple.toml @@ -12,7 +12,7 @@ strict = false audit = { mode = false, hash = "SHA-256" } timestamp = { default-time = 00:00:00, timezone = { name = "UTC" } } -input = { storage = "fs", fs = { dir = "simple", suffix = "txn" } } +input = { storage = "fs", fs = { path = "simple", dir = "txns", suffix = "txn" } } [transaction] accounts = { path = "none" } @@ -35,4 +35,4 @@ register = { title = "Register Report", accounts = [ "Assets:.*", "Expenses ### Export Configuration [export] targets = [ ] -equity = { accounts = [ "^Assets:", ], equity-account = "Equity:Balance" } +equity = { accounts = [ "Assets:.*", ], equity-account = "Equity:Balance" } diff --git a/examples/simple/journal.txn b/examples/simple/txns/journal.txn similarity index 100% rename from examples/simple/journal.txn rename to examples/simple/txns/journal.txn diff --git a/examples/tackler.toml b/examples/tackler.toml index bbdfa9b..ac3a16e 100644 --- a/examples/tackler.toml +++ b/examples/tackler.toml @@ -80,16 +80,16 @@ storage = "fs" ### Filesystem based input storage [kernel.input.fs] -### Top-level directory of storage tree -### -### This is the top level location of txn shard structure, -### the scanning is started from here. +### Path to the FS-storage ### ### If the directory path is relative, then it's based on this file. -### In case of CLI option, it's relative to the current working directory. +### When CLI --input.fs.dir is supplied, this option is ignored. +path = "tackler" ### +### This is root directory of txn shard structure, +### the scanning starts from here. ### CLI: --input.fs.dir -dir = "tackler/txns" +dir = "txns" ### Filename suffix ### ### This is transaction file extension, e.g. all files with @@ -116,7 +116,7 @@ suffix = "txn" ### selected by 'kernel.input.storage' ### ### CLI: --input.git.repo -repository = "tackler-data.git" +repo = "tackler-data.git" ### Git reference name ### ### This is git reference name (ref or symbolic ref). It is used diff --git a/perf/bin/perf-all.sh b/perf/bin/perf-all.sh index 9bb39d7..50bf844 100755 --- a/perf/bin/perf-all.sh +++ b/perf/bin/perf-all.sh @@ -79,3 +79,4 @@ done done done +(cd $data_dir; git checkout txns-1E3) diff --git a/perf/perf.toml b/perf/perf.toml index 79070dc..7eff9ce 100644 --- a/perf/perf.toml +++ b/perf/perf.toml @@ -8,8 +8,8 @@ timestamp = { default-time = 00:00:00, timezone = { name = "UTC" } } [kernel.input] storage = "git" -fs = { dir = "../../perf/data/perf-data", suffix = "txn" } -git = { repository = "../../perf/data/perf-data/.git", dir = "txns", suffix = "txn", ref = "txns-1E5" } +fs = { path = "../../perf/data/perf-data", dir = "txns", suffix = "txn" } +git = { repo = "../../perf/data/perf-data/.git", dir = "txns", suffix = "txn", ref = "txns-1E3" } [transaction] accounts = { path = "perf-accounts.toml" } diff --git a/suite b/suite index 84e42ce..8cfe685 160000 --- a/suite +++ b/suite @@ -1 +1 @@ -Subproject commit 84e42ce60c0b59d91543315b9ecd41960376b215 +Subproject commit 8cfe6850a7d403c54d1a63bfb4780cb3a477f3f9 diff --git a/tackler-cli/CRATES.md b/tackler-cli/CRATES.md index d1bcba5..e77660f 100644 --- a/tackler-cli/CRATES.md +++ b/tackler-cli/CRATES.md @@ -82,15 +82,19 @@ This setup doesn't have any checks enabled and it uses plain filesystem as trans #### Journal ```` -2024-12-01 'Sweet'n Sour Candies +2024-03-20 'Lucky Day! + Assets:Bank:Acme_Inc 420 + Income:Lottery + +2024-06-20 'Sweet'n Sour Candies Expenses:Sweets:Candy 2.50 Assets:Cash -2024-12-22 'Hot dogs +2024-09-22 'Hot dogs Expenses:Food:FastFood 12 Assets:Visa:4012_8888_8888_1881 -2024-12-22 'Strawberry ice cream +2024-12-21 'Strawberry ice cream Expenses:Sweets:Ice·Cream 3 Assets:Cash ```` diff --git a/tackler-core/src/config/items.rs b/tackler-core/src/config/items.rs index eae9e45..29e5ade 100644 --- a/tackler-core/src/config/items.rs +++ b/tackler-core/src/config/items.rs @@ -258,8 +258,12 @@ pub struct FS { } impl FS { fn from(fs_raw: &FsRaw) -> Result> { + let dir = match &fs_raw.path { + Some(path) => format!("{}/{}", path, fs_raw.dir), + None => fs_raw.dir.clone(), + }; Ok(FS { - dir: fs_raw.dir.clone(), + dir, suffix: fs_raw.suffix.clone(), }) } @@ -274,8 +278,18 @@ pub struct Git { } impl Git { fn from(git_raw: &GitRaw) -> Result> { + let repo = match &git_raw.repo { + Some(repo) => repo.clone(), + None => match &git_raw.repository { + Some(repo) => repo.clone(), + None => { + let msg = "Git is missing 'repo' key"; + return Err(msg.into()); + } + }, + }; Ok(Git { - repo: git_raw.repo.clone(), + repo, git_ref: git_raw.git_ref.clone(), dir: git_raw.dir.clone(), suffix: git_raw.suffix.clone(), diff --git a/tackler-core/src/config/raw_items.rs b/tackler-core/src/config/raw_items.rs index 968e631..9d31b83 100644 --- a/tackler-core/src/config/raw_items.rs +++ b/tackler-core/src/config/raw_items.rs @@ -64,6 +64,8 @@ pub(super) struct InputRaw { #[derive(Debug, Clone, Deserialize)] pub(super) struct FsRaw { + // new key + pub(super) path: Option, pub(super) dir: String, pub(super) suffix: String, } @@ -71,8 +73,10 @@ pub(super) struct FsRaw { #[allow(dead_code)] #[derive(Debug, Clone, Deserialize)] pub(super) struct GitRaw { - #[serde(rename = "repository")] - pub(super) repo: String, + // old key + pub(super) repository: Option, + // new key + pub(super) repo: Option, #[serde(rename = "ref")] pub(super) git_ref: String, pub(super) dir: String,