spade init
The spade init command scaffolds a new block collection project in the current directory. A collection is a set of related blocks that share a language and are versioned together.
Usage🔗
spade init --language <language>
spade init -l <language>The --language (or -l) flag is required. Supported values are:
| Value | Language marker file |
|---|---|
rust | Cargo.toml |
go | go.mod |
python | pyproject.toml |
typescript | package.json |
r | renv.lock |
The collection name is derived from the current directory name.
Scaffolded structures🔗
Each language produces a different project layout. In all cases, a blocks/ directory is created for block manifests.
Rust🔗
mkdir my-collection && cd my-collection
spade init -l rustmy-collection/
Cargo.toml # [package] with name and version
src/
lib.rs # Collection library root
blocks/ # Block manifest YAML filesThe generated Cargo.toml:
[package]
name = "my-collection"
version = "0.1.0"
edition = "2021"Go🔗
mkdir my-collection && cd my-collection
spade init -l gomy-collection/
go.mod # Module declaration
main.go # Collection entry point
blocks/ # Block manifest YAML filesThe generated go.mod uses the Go version of your current toolchain. The main.go file contains a stub main() function.
Python🔗
mkdir my-collection && cd my-collection
spade init -l pythonmy-collection/
pyproject.toml # Project metadata
src/
my_collection/ # Package directory (hyphens converted to underscores)
__init__.py
blocks/ # Block manifest YAML filesThe generated pyproject.toml:
[project]
name = "my-collection"
version = "0.1.0"
requires-python = ">=3.10"TypeScript🔗
mkdir my-collection && cd my-collection
spade init -l typescriptmy-collection/
package.json # Package metadata with main entry
src/ # Source directory for block handlers
blocks/ # Block manifest YAML filesThe generated package.json:
{
"name": "my-collection",
"version": "0.1.0",
"main": "src/index.ts"
}R🔗
mkdir my-collection && cd my-collection
spade init -l rmy-collection/
renv.lock # renv dependency lockfile
R/ # R scripts for block handlers
blocks/ # Block manifest YAML filesFlags🔗
| Flag | Short | Default | Description |
|---|---|---|---|
--language | -l | (required) | Language for the collection: rust, go, python, typescript, or r |
Workflow after scaffolding🔗
After running spade init, the typical next steps are:
- Add a block. Use
spade add <name>to create a block manifest and source file. - Implement the handler. Edit the generated source file to perform actual processing.
- Validate. Run
spade checkto verify manifests and entrypoints. - Install locally. Run
spade install file://.to build and register the collection. - Use in a pipeline. Reference your blocks by their
<collection>.<block>name in a pipeline YAML file.
Language detection🔗
Spade detects a collection's language by checking for marker files in the project root, in this order:
Cargo.toml-- Rustgo.mod-- Gopyproject.toml-- Pythonpackage.json-- TypeScript- If none of these are found, the collection defaults to R
This detection order is used by spade add, spade check, spade install, and spade publish whenever they need to determine the language of an existing collection.
See also🔗
spade addfor adding blocks to the scaffolded collection- Your First Block for a step-by-step tutorial
- Library documentation for language-specific details