Developer tools
The fubby command runs your programs, checks them, tests them, formats them and manages packages.
Commands
| Command | What it does |
|---|---|
fubby run file.fab | Check a program, then run its main function |
fubby check file.fab | Report every mistake it can find, without running anything |
fubby init folder | Create a starter project in a new folder |
fubby repl | Try one line at a time. Lines don't remember each other, and :quit exits |
fubby shady ... | Test, format, lint, debug, profile and document |
fubby pkg ... | Manage packages |
fubby snow serve file.fab | Run a web app |
fubby snow stop marker | Stop a web app cleanly |
fubby --version | Print the version, target and build details |
fubby --help | List the commands |
Commands exit with status 0 when they succeed and 1 when they fail, so they work in scripts.
Shady: tests
A test is a function with no parameters whose name starts with test_, in a file named test_*.fab or *_test.fab. Throw an error to fail it. Failures don't stop the remaining tests, and each test gets a fresh start.
func double(Int n) -> Int {
return n * 2
}
func test_double() {
if double(4) != 8 {
throw "expected 8"
}
}fubby shady test # every test file under this folder
fubby shady test math_test.fab # one file
Tests share files, databases and network access, so clean up after any that write data.
Formatting
The formatter fixes indentation to four spaces, removes trailing whitespace, and ends the file with a newline. It never moves your code onto different lines.
fubby shady fmt src # rewrite files
fubby shady fmt --check src # report only, and fail if changes are needed
Linting
The linter checks one file at a time, without following imports, and doesn't run anything. fubby check goes deeper.
| Code | Problem |
|---|---|
S001 | Trailing whitespace |
S002 | Tab indentation |
S003 | Duplicate function, class or interface |
S004 | Duplicate parameter |
Debugging and profiling
fubby shady debug file.fab runs a program and prints a trace of its function calls and variables. It stops tracing after 200 events. Breakpoints and stepping aren't available yet.
fubby shady profile file.fab runs a program and reports its run time, steps, calls and deepest call.
Documentation
fubby shady docs file.fab writes Markdown describing a file's declarations, including its /// comments. Add --output api.md to save it. It won't overwrite an existing file.
Smokey: packages
Smokey shares code between projects, using folders on your computer or a local registry folder. It never uses the network, so there's no public package registry yet.
Create a package and use it
fubby pkg init greeting
fubby pkg init app
cd app
fubby pkg add greeting --path ../greeting
fubby pkg validate
fubby pkg install
fubby pkg list
Installing writes a fubby.lock file and a .fubby/packages/ folder. Commit the lockfile, so everyone gets the same versions.
Then import a file from the package, using a path inside it. Its declarations join your program's single namespace.
import "package:greeting/src/lib.fab"
The manifest
Every package has a fubby.toml. Names use letters, digits, - and _, and versions have the form 1.2.3.
manifest-version = 1
[package]
name = "app"
version = "1.0.0"
fubby = ">=0.1.0, <0.2.0"
[dependencies]
text-util = "^1.0.0"
greeting = { version = "1.0.0", path = "../greeting" }
Constraints can be an exact version, a caret range such as ^1.2.3, or comparisons separated by commas. The fubby line states which Fubby versions the package works with.
All package commands
| Command | What it does |
|---|---|
fubby pkg init [folder] | Create a manifest and starter src/main.fab |
fubby pkg add name constraint | Add a dependency from a registry |
fubby pkg add name --path folder | Add a dependency from a local folder |
fubby pkg remove name | Remove a dependency |
fubby pkg install [--registry folder] | Resolve dependencies, copy them from local folders, and write the lockfile |
fubby pkg validate [--registry folder] | Check the manifest and dependencies |
fubby pkg list | List installed packages |
fubby pkg pack [archive] | Create an archive of the package |
fubby pkg verify archive | Check an archive |
fubby pkg publish --registry folder | Copy the package into a local registry. Never replaces an existing version |
You can set FUBBY_LOCAL_REGISTRY instead of passing --registry. Package code runs with your program's full access, and checksums detect changes but don't prove who wrote a package, so only install packages you trust.
Visual Studio Code
Install the Fubby plugin from the Marketplace, or run code --install-extension twigsoftware.fubby. It uses your installed fubby program, and adds:
- Syntax highlighting and a paw file icon for
.fabfiles - Errors underlined as you type, with deeper checks when you open or save a file
- Format Document, using Fubby's own formatter
- Completions and hover help for built-in functions and your own code
- Snippets for common code, such as
main,classandmatch - The Outline view, and Go to Definition across imports
- A Run button, and commands to check, test and serve