7 个版本 (破坏性更新)
0.6.0 | 2024年3月14日 |
---|---|
0.5.0 | 2024年3月5日 |
0.4.1 | 2022年2月19日 |
0.3.0 | 2022年1月25日 |
0.1.0 | 2022年1月4日 |
#794 in 解析器实现
87KB
2.5K SLoC
账本工具库
Ledger-cli 文件处理 Rust 库,用于计算余额、创建报告等。
use anyhow::{bail, Result};
use ledger_utils::{balance::Balance, Ledger};
fn main() -> Result<()> {
let ledger: Ledger = fs::read_to_string("finances.ledger")?.parse()?;
if ledger.transactions.is_empty() {
bail!("no transactions found");
}
let balance: Balance = (&ledger).into();
let mut assets: Vec<_> = balance
.account_balances
.iter()
.filter(|(name, _)| name.starts_with("Assets:"))
.collect();
assets.sort_by_key(|&(name, _)| name);
for (name, balance) in assets {
println!("{}: {}", name, balance);
}
Ok(())
}
依赖关系
~3MB
~58K SLoC