Skip to content
All guides

learn

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

  1. Numbers and text
  2. Arrays and lists
  3. Loops
  4. Functions
  5. Structs
  6. Errors
  7. Modules: split the files
  8. 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.