ON AIRTerminal of Tinsel

馃摵 Auntie Aerial's Night School

Build Terminal of Tinsel from nothing, in 24 nights

馃摵 "Good evening, and welcome to Night School. You've watched the Midwinter Special. Now you'll see how the picture gets made. Twenty-four nights, one door each, and by Christmas Eve you'll have built the whole thing yourself. Bring a pencil and a mince pie. Mind the tinsel."

This is a course in writing a real Rust command-line application, taught by building Terminal of Tinsel from an empty folder to a released program. Every night opens one door and adds one idea. You'll meet the standard library, clap for commands, serde for data, ratatui for interactive screens and jiff for dates, and you'll learn how to test, ship and release the lot.

Who it's for: anyone who can open a terminal and has written a little code in any language. You need no Rust, because we teach it as we go, ownership and borrowing included. If you already know Rust, skip to Night 11, where the interactive terminal starts.

How it works: each night takes 30 to 60 minutes. Nights 1 to 10 are build-along, where you type the code, run it and see it work. From Night 11 the program is too big to type, so those nights teach the ideas with the key code, and point at the finished files in this repository for the rest. Every night ends with an exercise ("Before morning") and a Rust fact ("Festive fact").

Call your project terminal-of-tinsel, as this repository does, so the commands and paths in the lessons match yours. You can rename it on the last night.

The course has a sister. Count Cathode's Night School builds Terminal of Terror in Go over the 31 nights of October. The two programs do the same things in two languages, and docs/go-to-rust.md compares them.

馃搮 The programme

Week 1 路 The First Doors: foundations

NightLessonYou'll learn
1Light the TreeInstalling Rust, cargo new, fn main, cargo run and cargo build
2The Running Orderclap: a Cli struct, --help, --version, subcommands and match
3Meet the GuestsStructs, Vec, String and &str, ownership and borrowing, a list command
4A Fact from the CrackerOption, a random generator of your own, seeds
5Data under the TreeJSON with serde, derive macros, include_str!
6Packs of CreaturesModules, one file per creature, include_dir!, a Vault

Week 2 路 By the Fire: errors, tests, colour and the first screen

NightLessonYou'll learn
7Speak Its NameResult and ?, an error type with codes, name lookup, "did you mean"
8Check It Twicecargo test, data tests, end-to-end tests, clippy and rustfmt
9Deck the TerminalColour, boxes, wrapping, terminal width, plain mode
10Every Creature in Its ColoursThemes, the creature page, ASCII portraits, --json
11Channel 25 Tunes Inratatui: raw mode, an event loop, drawing a frame
12Fitting the ScreenDividing the screen, wrapping, scrolling, testing screens without a terminal

Week 3 路 The Midwinter Special: the explorer and the games

NightLessonYou'll learn
13St Lucy's Night: Turn the PageSections and tabs, enums for state, lifetimes, a gallery with a cursor
14Whispers in the SnowSearch mode: text input, folding accents, snippets
15Your Host, Auntie AerialTicks, TV static, snow with no state, typewriter text
16Writing the CrackersGenerating quiz questions from data, hiding the answer, distractors
17The Christmas Cracker QuizA second screen, feedback, ranks, wiring a command
18Behind the Frosted WindowGuess the Guest: the frost, its reveal order, stages and points

Week 4 路 The Long Night: progress, rituals and release

NightLessonYou'll learn
19The Snowball ShowdownStats and a die, three rounds, narration for one creature or several
20What the Stocking RemembersSaving progress safely, captures and badges
21The Longest NightDates with jiff, the moon, advent doors, daily seeds
22Open the Doors--json everywhere, community packs from disk, validation
23The Night Before the Night BeforeTab completion, man pages, generated files, CI on three systems
24Christmas Eve: Sign OffThe changelog, cargo-dist, tagging a release, what next

Before Night 1

You'll need:

The finished program is in this repository. Whenever a lesson says "the full file in the repo", it means the file at the same path here, for example src/creatures.rs. Reading ahead is allowed and copying is encouraged, as long as you understand what you copy.

You don't have to wait for December, and you don't have to keep to one door a night.

馃摵 "Channel 25 will now begin its broadcast. Night 1 is this way."