Skip to content
Weaverv0.5.0

A project

A project is a folder with a weaver.toml, its manifest, beside its sources:

weaver.toml
[package]
name = "app"
weaver = "0.5" # the toolchain it builds with

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.

Terminal window
wv add weft/json

adds the latest version to weaver.toml, and installs it:

[dependencies]
"weft/json" = "1.0" # 1.0.0 or any later 1.x

The package is then imported under its name:

main.wft
import weaver.io.print
import weft.json.{Json, JsonError}
#Json
type 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.0 asks 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.

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
weaver-workspace.toml
[workspace]
members = ["greet", "hello"] # patterns too, "tools/*"
[dependencies]
"weft/json" = "1.0" # versions the members share

A member depends on another member, or on a version the workspace pins, with { workspace = true }, and no path or version of its own:

hello/weaver.toml
[package]
name = "hello"
[dependencies]
"acme/greet" = { workspace = true }
"weft/json" = { workspace = true }
hello/main.wft
import weaver.io.print
import 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 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.

Terminal window
wv run main.wft # compile and run
wv test # the project's tests, and its docs' examples
wv fmt . # the canonical formatting
wv doc main.wft # the documentation of its /// comments

wv 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.

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.