A project
A project is a folder with a weaver.toml, its manifest, beside its
sources:
[package]name = "app"weaver = "0.5" # the toolchain it builds withDependencies
Section titled “Dependencies”The packages a project uses, the wefts, come from the registry,
wefts.weaver-lang.dev, where each one has
its page, its versions and its documentation. A package is named by its
publisher, then its name: the official ones are published by weft,
weft/json, weft/cli.
wv add weft/jsonadds the latest version to weaver.toml, and installs it:
[dependencies]"weft/json" = "1.0" # 1.0.0 or any later 1.xThe package is then imported under its name:
import weaver.io.printimport weft.json.{Json, JsonError}
#Jsontype Release = { tag: String, assets: String[] }
fn main() ! JsonError { val r = Json.decode<Release>("{\"tag\": \"v0.1.0\", \"assets\": [\"install.sh\"]}")! print("${r.tag}: ${r.assets.len()} asset(s)")}#Json is an annotation: at compile time, code written in Weaver reads the
Release type and writes its decoder. wv expand main.wft shows what it
generated.
wv add weft/json@1.0asks for a version; the constraints follow Cargo’s,~1.4,=1.4.2,>=1.2, <3.wv add -dev weft/…adds a package the tests alone use, under[dev-dependencies].- A dependency can also come from a folder,
{ path = "../json" }, or from a git repository,{ git = "https://…/json.git", rev = "v1.2" }.
Each archive downloaded is checked against the registry’s signed index before it is extracted.
Workspaces
Section titled “Workspaces”Several packages that live together, a library and the programs that use
it, form a workspace: a weaver-workspace.toml at their common root
lists them.
acme/├── weaver-workspace.toml├── greet/ the library acme/greet│ ├── weaver.toml│ └── greet.wft└── hello/ a program that uses it ├── weaver.toml └── main.wft[workspace]members = ["greet", "hello"] # patterns too, "tools/*"
[dependencies]"weft/json" = "1.0" # versions the members shareA member depends on another member, or on a version the workspace pins,
with { workspace = true }, and no path or version of its own:
[package]name = "hello"
[dependencies]"acme/greet" = { workspace = true }"weft/json" = { workspace = true }import weaver.io.printimport acme.greet.greeting
fn main() { print(greeting("world"))}The members share one weaver.lock and one bin/, at the workspace’s
root. There, wv build builds every member and wv test tests each one,
-p picks one, wv test -p acme/greet; from a member’s folder, commands
target that member alone.
The lock file
Section titled “The lock file”The first build writes weaver.lock: each package’s version and the hash
of its sources. Commit it, and the project builds the same everywhere,
without asking the registry again. wv update resolves the dependencies
anew, wv update weft/json that one alone.
Everyday commands
Section titled “Everyday commands”wv run main.wft # compile and runwv test # the project's tests, and its docs' exampleswv fmt . # the canonical formattingwv doc main.wft # the documentation of its /// commentswv alone lists every command and its options.
Builds and tasks shows how to name builds,
and how to script the rest of a project with wv wake.
The official wefts
Section titled “The official wefts”Published by weft on the registry,
which documents each of them:
| Package | |
|---|---|
weft/cli |
The command line of a program, described by a type: #Cli writes its parsing, help and errors |
weft/compress |
deflate, zlib and gzip |
weft/config |
A typed configuration merged from files, the environment and the command line |
weft/csv |
CSV, RFC 4180: rows read as a stream, written, and a table by header |
weft/encoding |
Base64, base32, percent-encoding and UTF-16 |
weft/images |
Pixel buffers and the formats that read and write them, PNG first |
weft/inject |
Dependency injection resolved at compile time |
weft/json |
JSON: a value, a streaming reader and writer, and #Json |
weft/regex |
POSIX extended regular expressions, compiled at run time or at compile time |
weft/rest |
HTTP services described by contracts: #Rest generates the router and the client |
weft/terminal |
Colors, messages, spinners, progress bars and choices on a terminal |
weft/toml |
TOML 1.0.0 and #Toml |
weft/unicode |
Unicode character classes |
weft/wake |
Tasks written in Weaver, wv wake |
weft/width |
The display width of a character in a terminal |
weft/xml |
XML 1.0 and its namespaces: events, a tree, and #Xml |
The standard library, weaver.*, comes with the toolchain: its
guides introduce it, and wv doc weaver lists its API.