Skip to content

Init Command

Quick Start with Init

The rustywatch init command scans your project tree and writes a configuration file, so a monorepo is set up in one step.

Basic Usage

Terminal window
rustywatch init

This:

  1. Scans the current directory and its subdirectories for known project markers
  2. Lists everything found and lets you pick which projects to watch
  3. Fills in the command, binary path, ignore patterns and .env file for each
  4. Optionally walks you through customizing every field
  5. Validates the result and shows a preview before writing rustywatch.yaml

Nothing is written until the config passes the same validation rustywatch itself applies, so init cannot leave you with a file that fails to load.

Command Options

FlagDescription
-o, --output <FILE>Config file path (default: rustywatch.yaml)
-d, --dir <DIR>Root directory to scan (default: .)
--depth <N>How deep to scan for nested projects (default: 2; 0 = only the root)
--yesSkip prompts and accept every detected project as-is
-f, --forceOverwrite an existing config file
--dry-runPrint the configuration instead of writing it

--yes never blocks on a prompt: if the output file already exists it errors and asks for --force rather than waiting for an answer. Running init without --yes outside a terminal errors for the same reason.

Multi-project scanning

Given this tree:

shop/
├── Cargo.toml # Rust
├── services/
│ └── api/go.mod # Go
├── web/
│ ├── package.json # Node.js
│ └── .env
└── node_modules/ # skipped

rustywatch init --yes produces all three workspaces at once:

workspaces:
- dir: .
cmd: cargo build
ignore:
- target/
- .git/
bin_path: ./target/debug/shop
- dir: services/api
cmd: go build
ignore:
- vendor/
- .git/
bin_path: ./api
- dir: web
cmd: npm run dev
ignore:
- node_modules/
- .git/
- dist/
- .next/
env_file: .env

Build output and dependency directories (target/, node_modules/, vendor/, dist/, build/, out/, coverage/, __pycache__/, venv/) and hidden directories are never descended into, so vendored copies of a project are not mistaken for the real thing.

Use --depth 0 to look only at the root, or raise it for deeper trees.

Auto-Detection

RustyWatch detects the project type and reads the manifests to pick defaults that point at things which actually exist:

Project TypeDetection FileDefault CommandDefault Binary
RustCargo.tomlcargo build./target/debug/{name}
Gogo.modgo build./{name}
Node.jspackage.jsonfirst of dev/start/serve/watch in scripts, else npm run dev-
Bunbun.lockbsame, run with bun-
Pythonpyproject.toml, setup.py, requirements.txtpython <main/app/manage/run/__main__>.py-
Other-placeholder to edit-

The project name comes from Cargo.toml, package.json or go.mod, falling back to the directory name. When a workspace has a .env file it is wired up as env_file automatically.

Examples

Interactive setup:

Terminal window
rustywatch init

Accept everything detected:

Terminal window
rustywatch init --yes

Preview without writing:

Terminal window
rustywatch init --yes --dry-run

Scan a subdirectory only:

Terminal window
rustywatch init --dir services --depth 1

Custom output path:

Terminal window
rustywatch init -o .rustywatch.yaml

Force overwrite existing config:

Terminal window
rustywatch init --yes --force

Interactive Prompts

When projects are detected you are asked:

  1. Which projects to watch — a multi-select, everything pre-selected (space toggles, enter confirms)
  2. Whether to customize — answer no to keep the detected settings

Choosing to customize (or having nothing detected) walks each workspace through:

  1. Watch directory — must be an existing directory
  2. Build/run command — required, runs inside the watch directory
  3. Binary path — leave empty for interpreted projects
  4. Binary arguments — space-separated, only asked when a binary is set
  5. Ignore patterns — comma-separated, rejected if a pattern is not a valid glob
  6. Env file — leave empty for none

You can then add further workspaces by hand before the preview is shown.