Developer tools

The fubby command runs your programs, checks them, tests them, formats them and manages packages.

Commands

CommandWhat it does
fubby run file.fabCheck a program, then run its main function
fubby check file.fabReport every mistake it can find, without running anything
fubby init folderCreate a starter project in a new folder
fubby replTry 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.fabRun a web app
fubby snow stop markerStop a web app cleanly
fubby --versionPrint the version, target and build details
fubby --helpList 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.

math_test.fab
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.

CodeProblem
S001Trailing whitespace
S002Tab indentation
S003Duplicate function, class or interface
S004Duplicate 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

CommandWhat it does
fubby pkg init [folder]Create a manifest and starter src/main.fab
fubby pkg add name constraintAdd a dependency from a registry
fubby pkg add name --path folderAdd a dependency from a local folder
fubby pkg remove nameRemove 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 listList installed packages
fubby pkg pack [archive]Create an archive of the package
fubby pkg verify archiveCheck an archive
fubby pkg publish --registry folderCopy 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: