Stitches
What are stitches?
Frankie's zero-dependency, zero-registry package system. Drop a .fk file in the right folder and stitch it in.
| Feature | Category | Summary |
|---|---|---|
stitch "name" |
language | Load a package by name — resolves from ./stitches/ then ~/.frankie/stitches/ |
frankiforms |
stitch | Form field validation — required, min/max length, email, numeric, pattern |
frankitable |
stitch | ASCII table rendering from a vector of hashes |
frankicolor |
stitch | ANSI color helpers for terminal output |
frankipager |
stitch | Pagination math — total pages, slicing, prev/next |
frankiconfig |
stitch | Layered config loading from defaults, JSON file, and env vars |
frankistring |
stitch | Additional string functions |
frankietemplate |
stitch | Mustache-compatible template rendering for Frankie |
frankiecookie |
stitch | Signed cookie helpers for Frankie |
| --- |
The stitch Keyword
stitch loads a Frankie package by name. It resolves the file in two locations, in order:
./stitches/<name>.fk— project-local (checked first)~/.frankie/stitches/<name>.fk— user-global
If neither exists, a clear error tells you exactly what to do:
╔══ Frankie Runtime Error ══════════════════════════════
║ [Frankie] Stitch not found: "frankiforms"
║ Put frankiforms.fk in ./stitches/ or ~/.frankie/stitches/
╚═══════════════════════════════════════════════════════
Each stitch is loaded at most once — calling stitch "name" multiple times in the same program is safe.
Compared to require
require |
stitch |
|
|---|---|---|
| Path | Explicit: require "lib/utils" |
By name: stitch "frankiforms" |
| Resolution | Relative to cwd | ./stitches/ then ~/.frankie/stitches/ |
| Signals | Your own code | Third-party packages |
| Convention | lib/ folder |
stitches/ folder |
They use the same underlying machinery — stitch is require with a conventional resolution path and a more meaningful name for the job.
Project layout with stitches
myapp/
├── main.fk
├── test.fk
├── lib/
│ └── utils.fk ← your own code, loaded with require
└── stitches/
├── frankiforms.fk ← third-party, loaded with stitch
└── frankitable.fk
Anyone cloning your repo immediately knows what stitches/ contains.
Writing Your Own Stitch
A stitch is any .fk file. Drop it in ./stitches/ and stitch "name" loads it.
# stitches/myutils.fk
def slugify(s)
s.downcase.gsub("[^a-z0-9]+", "-").strip
end
def truncate(s, n)
if s.length <= n
s
else
s[0...n] + "..."
end
end
# main.fk
stitch "myutils"
puts slugify("Hello World!") # hello-world
puts truncate("Long string", 4) # Long...
Conventions
- Prefix private helper functions with
_to signal they're internal. - Use
##doc-comments forfrankiec docscompatibility. - Keep each stitch focused on one concern.
- Avoid redefining stdlib functions.