acton fmt
Reference manual for the acton fmt command
Synopsis
acton fmt [options] [paths...]
Description
Format .tolk files using the built-in Tolk formatter.
The command can rewrite files in place or run in --check mode for CI and
pre-commit validation. If no _paths_ are provided, Acton scans the resolved
project root recursively.
For editor integrations, acton fmt --stdin reads one Tolk source buffer from
standard input and writes only the formatted source to standard output.
Options
Format Options
Files or directories to format.
Acton scans the project root.
--stdin
May be passed multiple times.
Check formatting without rewriting files.
In this mode Acton prints diffs for mismatches and exits non-zero.
Read Tolk source from standard input and write formatted source to standard output.
This mode is intended for editor and IDE integrations. It does not rewrite files
and, unless combined with --check, does not print status messages to standard
output.
paths
Virtual file path to use for diagnostics when formatting source from standard input.
This option is accepted only with --stdin. Acton does not read or write this
path.
Format only the specified zero-based source range.
This is intended for editor integrations that format a selected region. Lines
are zero-based, and startChar / endChar are zero-based UTF-8 byte columns.
Editor integrations that expose Unicode scalar or UTF-16 positions need to
convert them before invoking Acton.
Display Options
Control when to use colored output.
auto, always, never
auto
Project Options
Path to the Acton.toml file to use for this invocation.
Use this when running the command outside the project directory or when the manifest lives at a non-default location.
--project-root
Path to the project root to use for configuration discovery and relative defaults.
--manifest-path
Behavior
- Only
.tolkfiles are formatted - Directory traversal is recursive
- Built-in ignore globs always apply, including
node_modules,.git,target, and.acton - explicit file arguments are formatted even if they would match
[fmt].ignore - directory traversal applies
[fmt].ignoreand built-in excludes to relative and absolute paths - Syntax errors are reported as diagnostics and cause a non-zero exit
--checkprints a unified diff with three lines of context for each changed file--stdinwrites only formatted source to stdout; diagnostics and errors go to stderr--stdin --checkcompares stdin with formatted output and prints a unified diff if formatting would change--rangekeeps nodes outside the specified range unchanged and disables import reordering for that invocation--rangecan only be used with one explicit.tolkfile path, unless--stdinis used
Configuration
acton fmt reads defaults from [fmt] in Acton.toml:
[fmt]
width = 100
ignore = ["contracts/generated/*.tolk"]
separate-import-groups = trueUseful fields include:
widthfor maximum formatted line widthignorefor additional exclude globsseparate-import-groupsfor blank lines between import groups
Import Sorting
Imports are sorted by group in this order:
@stdlib@acton- other
@...imports - plain imports
./...../...
Within each group, imports are sorted lexicographically.
Exit Status
0: All requested files were formatted successfully, or--checkfound no formatting differences.1: Files needed formatting in--checkmode, syntax errors prevented formatting, or path resolution failed.
Examples
-
Format all Tolk files in the project:
acton fmt -
Format selected paths:
acton fmt contracts scripts/deploy.tolk -
Validate formatting without writing files:
acton fmt --check -
Run against another project root:
acton --project-root ../my-project fmt --check -
Check import grouping after enabling blank lines between groups:
acton fmt contracts/main.tolk --check -
Format only a selected source range:
acton fmt contracts/main.tolk --range 2:4-5:1 -
Format an editor buffer through stdin/stdout:
acton fmt --stdin --stdin-filepath contracts/main.tolk < contracts/main.tolk
See Also
acton help check- Formatting guide
Last updated on