CashFlow
CashFlow is a multi-purpose utility tool for tracking and managing data entries from the terminal. It provides a simple log-based system for adding, listing, searching, and exporting entries with timestamped records.
Commands
| Command | Description |
|---|
| INLINECODE0 | Execute the main function with given arguments |
| INLINECODE1 |
Show configuration file location (
config.json) |
|
cashflow status | Show current status (ready/not ready) |
|
cashflow init | Initialize the data directory |
|
cashflow list | List all entries in the data log |
|
cashflow add <entry> | Add a new dated entry to the data log |
|
cashflow remove <entry> | Remove an entry |
|
cashflow search <term> | Search entries (case-insensitive grep) |
|
cashflow export | Export all data to stdout |
|
cashflow info | Show version and data directory path |
|
cashflow help | Show all available commands |
|
cashflow version | Show version number |
How It Works
CashFlow uses a flat-file approach. All entries are stored in data.log as dated lines (YYYY-MM-DD <content>). Every command also appends a timestamped record to history.log for auditing.
- -
add appends a new line with today's date - INLINECODE17 prints the full data log
- INLINECODE18 performs case-insensitive matching via INLINECODE19
- INLINECODE20 dumps the raw data log to stdout for piping/redirection
Data Storage
All data is stored locally in ~/.local/share/cashflow/ by default:
- -
data.log — Main data file with all entries (one per line, date-prefixed) - INLINECODE23 — Timestamped audit trail of every command executed
- INLINECODE24 — Configuration file (referenced by
cashflow config)
Override the storage location by setting the CASHFLOW_DIR environment variable:
CODEBLOCK0
Alternatively, XDG_DATA_HOME is respected if CASHFLOW_DIR is not set.
Requirements
- - bash 4+ (uses
set -euo pipefail for strict mode) - Standard Unix tools (
grep, date, cat) - No API keys needed
- No external dependencies
When to Use
- 1. Quick data logging — Use
cashflow add to rapidly log entries (expenses, tasks, notes) with automatic date stamps - Reviewing stored entries — Run
cashflow list to see everything you've logged, or cashflow search to find specific entries - Exporting data for analysis — Use
cashflow export > data.csv to dump all entries for import into spreadsheets or other tools - Project initialization — Run
cashflow init to set up the data directory on a new machine or project - Checking tool status — Use
cashflow status and cashflow info to verify the tool is ready and see version/path information
Examples
CODEBLOCK1
CODEBLOCK2
CODEBLOCK3
Output
All command output goes to stdout. The history log is always written to $DATA_DIR/history.log. Redirect output as needed:
CODEBLOCK4
Configuration
| Variable | Purpose | Default |
|---|
| INLINECODE41 | Override data/config directory | INLINECODE42 |
| INLINECODE43 |
Fallback base directory |
~/.local/share/ |
Powered by BytesAgain | bytesagain.com | hello@bytesagain.com
CashFlow
CashFlow 是一款多用途实用工具,用于在终端中跟踪和管理数据条目。它提供了一个基于日志的简单系统,支持添加、列出、搜索和导出带有时间戳记录的条目。
命令
| 命令 | 描述 |
|---|
| cashflow run <参数> | 使用给定参数执行主函数 |
| cashflow config |
显示配置文件位置(config.json) |
| cashflow status | 显示当前状态(就绪/未就绪) |
| cashflow init | 初始化数据目录 |
| cashflow list | 列出数据日志中的所有条目 |
| cashflow add <条目> | 向数据日志添加新的带日期条目 |
| cashflow remove <条目> | 移除一个条目 |
| cashflow search <关键词> | 搜索条目(不区分大小写的 grep 搜索) |
| cashflow export | 将所有数据导出到标准输出 |
| cashflow info | 显示版本和数据目录路径 |
| cashflow help | 显示所有可用命令 |
| cashflow version | 显示版本号 |
工作原理
CashFlow 采用平面文件方式。所有条目以带日期的行(YYYY-MM-DD <内容>)形式存储在 data.log 中。每个命令还会将带时间戳的记录追加到 history.log 中,用于审计。
- - add 使用当前日期追加新行
- list 打印完整的数据日志
- search 通过 grep 执行不区分大小写的匹配
- export 将原始数据日志转储到标准输出,以便管道/重定向
数据存储
默认情况下,所有数据存储在本地 ~/.local/share/cashflow/ 目录中:
- - data.log — 包含所有条目的主数据文件(每行一个,带日期前缀)
- history.log — 每个已执行命令的带时间戳审计跟踪
- config.json — 配置文件(由 cashflow config 引用)
通过设置 CASHFLOW_DIR 环境变量覆盖存储位置:
bash
export CASHFLOW_DIR=$HOME/my-data/cashflow
或者,如果未设置 CASHFLOWDIR,则会使用 XDGDATA_HOME。
要求
- - bash 4+(使用 set -euo pipefail 严格模式)
- 标准 Unix 工具(grep、date、cat)
- 无需 API 密钥
- 无外部依赖
使用场景
- 1. 快速数据记录 — 使用 cashflow add 快速记录条目(支出、任务、笔记),自动添加日期戳
- 查看存储的条目 — 运行 cashflow list 查看所有已记录内容,或使用 cashflow search 查找特定条目
- 导出数据进行分析 — 使用 cashflow export > data.csv 转储所有条目,以便导入电子表格或其他工具
- 项目初始化 — 在新机器或新项目上运行 cashflow init 设置数据目录
- 检查工具状态 — 使用 cashflow status 和 cashflow info 验证工具是否就绪,并查看版本/路径信息
示例
bash
初始化数据目录
cashflow init
添加条目
cashflow add 月租金支付 2500
cashflow add 收到自由职业发票 8000
cashflow add 杂货购物 350
列出所有条目
cashflow list
bash
搜索特定条目
cashflow search rent
cashflow search invoice
将数据导出到文件
cashflow export > my-records.txt
检查状态和信息
cashflow status
cashflow info
bash
运行自定义操作
cashflow run process-monthly
查看配置位置
cashflow config
移除一个条目
cashflow remove 旧条目
显示版本
cashflow version
输出
所有命令输出到标准输出。历史日志始终写入 $DATA_DIR/history.log。根据需要重定向输出:
bash
cashflow list > all-entries.txt
cashflow export | grep 2026-03 > march-data.txt
配置
| 变量 | 用途 | 默认值 |
|---|
| CASHFLOWDIR | 覆盖数据/配置目录 | ~/.local/share/cashflow/ |
| XDGDATA_HOME |
备用基础目录 | ~/.local/share/ |
由 BytesAgain 提供技术支持 | bytesagain.com | hello@bytesagain.com