Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
carderne committed Jan 24, 2024
1 parent 76a702c commit abbca0f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
30 changes: 23 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Basic [beancount](https://github.com/beancount/beancount) clone (one day...) in Rust!

Using [pest](https://pest.rs/) for parsing. Two useful links:
- [pest bootstrap parsing](https://github.com/pest-parser/pest/tree/master/meta/src)
- [playground](https://pest.rs/#editor)
Still very very alpha and doesn't do most things that are necessary to be at all useful.

Using [pest](https://pest.rs/) for parsing.

Planned features:
- [x] Parse beancount files
Expand All @@ -16,11 +16,13 @@ Planned features:
- [x] Validate `balance` directives
- [x] Pad statements
- [x] Open/close with multiple currencies
- [ ] Support `includes`
- [ ] Come up with a more punny name
- [ ] Currency conversions
- [ ] Price/cost and FIFO
- [ ] Add Python bindings

## (Deliberate*) differences from beancount
- Permitted transaction flags are limited to `*` `!` `txn`
## (Deliberate) differences from beancount
- Postings can't omit the currency

## Usage
Expand All @@ -30,20 +32,34 @@ cargo install bean-rs
```

### Run
```
```bash
$ bean-rs

Usage: bean-rs <COMMAND>

Commands:
balance
balance Display account balances
check Check for errors and quit
help Print this message or the help of the given subcommand(s)

Options:
-h, --help Print help
-V, --version Print version
```

#### Calculate balances
```bash
bean-rs balance example.bean
```


## Development
### Build
```bash
make build
```

### Test
```bash
make test
```
2 changes: 1 addition & 1 deletion grammar.pest
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ at_price = { "@" ~ (space+ ~ number)? ~ space+ ~ ccy }
metadata_added = _{ (NEWLINE ~ metadata) }
metadata = { space+ ~ key ~ ":" ~ space* ~ val }

txn_type = { "*" | "!" | "txn" }
txn_type = { "*" | "!" | "txn" | ASCII_ALPHA+ }
key = @{ ASCII_ALPHA_LOWER ~ (ASCII_ALPHANUMERIC | "-" ~ ASCII_ALPHANUMERIC)* }
tagkey = @{ ASCII_ALPHANUMERIC ~ (ASCII_ALPHANUMERIC | "-" ~ ASCII_ALPHANUMERIC)* }
val = @{ quoted | ASCII_ALPHA* }
Expand Down
2 changes: 1 addition & 1 deletion src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ pub struct Transaction {
ty: String,
payee: Option<String>,
narration: String,
tag: Option<String>, // TODO can have multiple
tag: Option<String>, // TODO can have multiple
link: Option<String>, // TODO can have multiple
pub postings: Vec<Posting>,
meta: Vec<Metadata>,
Expand Down
6 changes: 3 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use crate::directives::{DebugLine, Directive};

#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub enum ErrorType {
Parse, // parse error from Pest
Into, // error while going into `root` pair
Badline, // un-parseable line found in input
Parse, // parse error from Pest
Into, // error while going into `root` pair
Badline, // un-parseable line found in input
MultipleEmptyPostings,
UnbalancedTransaction,
NoAccount,
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ fn load(text: String) -> (Vec<Directive>, Vec<BeanError>) {
(dirs, errs)
}

/// Load the file at `path` and print the balance
/// Load the file at `path`
/// Optionally print the balance if `print_bals=true`
pub fn balance(path: &String, print_bals: bool) {
let text = std::fs::read_to_string(path).expect("cannot read file");
let (mut dirs, mut errs) = load(text);
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ struct Cli {

#[derive(Subcommand)]
enum Commands {
/// Display account balances
Balance { path: String },
/// Check for errors and quit
Check { path: String },
}

Expand Down

0 comments on commit abbca0f

Please sign in to comment.