Guided: a banking CLI
From here through the ledger becomes an app we build one program. Same idea, more language each chapter, then modules, then a live API.
What it will do by the last lesson:
- Print a greeting (this page)
- Record deposits and withdrawals in cents
- Store them in a list and loop a balance
- Reject overdrafts with a visible error
- Split into modules
- Serve accounts and a ledger over Keel and pack a ship
Start a CLI:
buraaq new ledger --cli
cd ledger
Replace src/main.bq with:
fn main() {
println("Ledger ready")
}
buraaq run
println imports itself. There is no use list yet. We use cents (int) so we do not fight floating-point money. 5000 means $50.00.
The path
- Numbers and text
- Arrays and lists
- Loops
- Functions
- Structs
- Errors
- Modules: split the files
- The ledger becomes an app: Keel + pack
Do not skip to Servers until this ledger compiles in your head. Then we put the same idea on the network without changing language.
