Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge from Dev #2

Merged
merged 24 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d44df91
Add pta link to readme
jb-intellinet Sep 25, 2023
379c633
create CI workflow
jb-intellinet Sep 25, 2023
29030c3
Merge branch 'main' into dev
jburnett Sep 25, 2023
a4d23c4
Initial code migrated from other project
jb-intellinet Sep 25, 2023
54b9b65
Rm'd extraneous ledger module; minor edits
jb-intellinet Sep 25, 2023
233de32
Add CLI to verify accessibility and for future impl
jb-intellinet Sep 25, 2023
74f04e2
WIP: Cli parses basic ledger
jb-intellinet Sep 26, 2023
5c16d57
Fix commodity directive
jb-intellinet Sep 26, 2023
ef7db73
WIP: multiple comment tokens; CLI output
jb-intellinet Sep 28, 2023
8d5e3b4
trans block parses
jb-intellinet Oct 7, 2023
bc7f9fa
Refactor parser tests
jb-intellinet Oct 7, 2023
d536884
add simple transactions to ledger file
jb-intellinet Oct 9, 2023
2f9d33b
Consolidate pest rules to simplify
jb-intellinet Oct 9, 2023
cbec9e3
WIP: consuming parser
jb-intellinet Oct 11, 2023
7771172
Removed pest_consume
jb-intellinet Oct 18, 2023
c96a3af
vscode settings
jb-intellinet Oct 18, 2023
1beb7fd
moving parse handling to builder; refactor cli to use it
jb-intellinet Oct 19, 2023
e71cc92
WIP: LedgerBuilder, logging
jb-intellinet Oct 24, 2023
ae844cc
Fix warnings
jb-intellinet Dec 15, 2023
b78b9f8
Begin multiple grammar support
jb-intellinet Dec 15, 2023
ab9e28b
v0.2.0 - multi-grammar support
jb-intellinet Dec 15, 2023
2a9b29d
pkg upgrades
jb-intellinet May 20, 2024
cb00a3f
Upgrade log to 0.4.21 & adapt warn macro
Jun 4, 2024
6396bbb
Rm warnings on unused workspace repos info
Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"rust-analyzer.linkedProjects": [
"./cli/Cargo.toml",
"./pta-ledger/Cargo.toml",
"./pta-parser/Cargo.toml",
"./pta-types/Cargo.toml"
]
}
19 changes: 19 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) 2023, AltaModa Technologies, LLC. All rights reserved.
#
# This project is licensed under the terms of the MIT license (cf. LICENSE file in root).

[workspace]
resolver = "2"
members = [
"cli"
,"pta-ledger"
,"pta-parser"
,'pta-types',
]

# Default values for workspace projects
[workspace.package]
edition = "2021"
version = "0.2.0"
authors = ["AltaModa Technologies"]
# respository = "https://github.com/altamodatech/pta-parser"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pta-parser

A Plain Text Accounting parser built in [Rust](https://www.rust-lang.org/) with [Pest](https://pest.rs/)
A [Plain Text Accounting](https://plaintextaccounting.org/) parser built in [Rust](https://www.rust-lang.org/) with [Pest](https://pest.rs/)

## Copyright Notice

Expand Down
19 changes: 19 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) 2023, AltaModa Technologies, LLC. All rights reserved.
#
# This project is licensed under the terms of the MIT license (cf. LICENSE file in root).

[package]
name = "cli"
version.workspace = true
authors.workspace = true
# respository.workspace = true
edition.workspace = true


[dependencies]
log = "0.4.21"
pest = "2.7.3"
pretty_env_logger = "0.5.0"
pta-ledger = { path = "../pta-ledger" }
pta-parser = { path = "../pta-parser" }
pta-types = { path = "../pta-types" }
67 changes: 67 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright (C) 2023, AltaModa Technologies, LLC. All rights reserved.
//
// This project is licensed under the terms of the MIT license (cf. LICENSE file in root).
//

extern crate pta_ledger;
extern crate pta_parser;


use log::{info, warn, error};

// TODO: how to isolate pest so clients can just use lib (w/o requiring pest as here)
use pta_ledger::ledger_builder::LedgerBuilder;



fn main() -> Result<(), Box<dyn std::error::Error>> {
// TODO: CLI improvements
// - exec with path of file to parse
// - optionally output parse results (should be equivalent to input file)

// TODO: consider flag to use init_timed to include time per line
pretty_env_logger::init();

let pb = std::env::current_dir()?;
let p = pb.join("testdata/basic-ledger");

info!("Input file: {:?}", p);

let mut bldr = LedgerBuilder::default();
match std::fs::read_to_string(p) {
Ok(ledger) => {
info!("String length from input: {}", ledger.len());
match bldr.from_string(&ledger) {
Ok(_parsed) => {
info!("Successfully parsed into ParsedLedger");
return Ok(());
},

Err(e) => {
error!("LedgerBuilder failed with {:}", e);
return Err(e);
}
}
}

Err(e) => {
warn!("failed to read file as string; {e}");
return Err(Box::new(e));
}
}

}



#[cfg(test)]
mod cli_tests {

use pta_parser::parsers::generic::Parser;

#[test]
fn can_create_parser() {
// simply verifies that the parser can be instantiated, ensuring accessibility
let _ = Parser{};
}
}
7 changes: 7 additions & 0 deletions journal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Plain-Text Accounting Parser

## History

### 10/18/2023

Abandonded effort to integrate [pest_consume](https://lib.rs/crates/pest_consume) since the author is no longer maintaining it.
24 changes: 24 additions & 0 deletions pta-ledger/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (C) 2023, AltaModa Technologies, LLC. All rights reserved.
#
# This project is licensed under the terms of the MIT license (cf. LICENSE file in root).

[package]
name = "pta-ledger"
version.workspace = true
authors.workspace = true
# respository.workspace = true
edition.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
bench = false

[dependencies]
log = { version = "0.4.20", features = ["kv_unstable", "kv_unstable_serde"] }
pest = "2.7.3"
pest_derive = "2.7.3"
pta-parser = { path = "../pta-parser" }
pta-types ={ path = "../pta-types" }

[dev-dependencies]
rstest = "0.19.0"
Loading
Loading