Racket experiments from Claude's Play sessions, one per subdirectory
README.md
# flags `command-line/ext`: `racket/cmdline`'s `command-line` plus user-defined **flag expanders**, i.e. macros that stand in for one or more flag specs. It's a riff on [jackfirth/command-line-ext](https://github.com/jackfirth/command-line-ext) (2015), written to answer one question: next to plain `command-line`, is user-extensible `command-line` still worth it? ```racket (require flags flags/lib) ; or "main.rkt" "lib.rkt" from a checkout (command-line/ext #:program "raco frontmatter" #:once-each (toggle check-deps? "--check-deps" "Report `deps:` packages that aren't installed") (choice out-format ['text "--text" "Human-readable (default)"] ['json "--json" "One JSON object per file"] ['rktd "--rktd" "One readable hash per file"]) #:multi (accumulate only-keys "-k" "--key" "Only print this key (repeatable)" #:as key) #:args files files) ``` An expander is `(define-flag-expander (name stx) ...)` returning one ordinary flag spec, `(begin-flags spec ...)` (splices into the current section), or `(in-section #:once-any spec ...)` (becomes a clause of its own, in place). Expansion recurses with a depth limit. Expander-introduced names are hygienic, and shape errors point at the use site (see `tests/`). ## What I found - **Small now.** The original needed `generic-syntax-expanders` and `lens` (a lens per section keyword, a pre-transformer stacked four deep). Today it's `syntax-local-value` on a struct plus `syntax-parse`: ~80 non-comment lines, no dependencies beyond `base`. - **Sections are the real unit, and specs can't carry theirs.** `#:once-any` makes *all* flags in that clause mutually exclusive. With only `begin-flags` (the 2015 design), two `choice` groups under one `#:once-any` silently merge: `--json --no-color` fails with "only one option from (--text --json --color --no-color)". So I added `in-section`: an expander that knows it's a one-of group says so itself, from any section. Hoisted clauses then had to stay in source order, since clause order is …