Format command
Formats SysML v2 models according to a consistent style. Useful when working in a team
and using version control systems to prevent whitespace-only changes in history.
--check reports what would change without writing anything, which is the form a
pipeline or a commit hook wants.
Basic usage
Format specific files
syside format /path/to/formatted_model.sysml /path/to/formatted_model_2.sysml
Format all files in current directory recursively
syside formatNote
When using
syside formatwithout explicitly listing out the files, Syside ignores hidden files and files from hidden directories (starting with., e.g..venvor.git). To format files from these directories, list them explicitly.
Output
After running the format command, you should see output similar to:
$ syside format
/path/to/formatted_model.sysml: formatted
1 file reformatted, 0 files left unchanged
The output shows the path of the file(s) that were reformatted, as well as the number of files that did not need reformatting.
Check mode
The syside format --check command can act as a quality gate without editing the
files. When a file needs reformatting, the output names it:
/path/to/formatted_model.sysml: would be formatted
1 file would be reformatted, 0 files already formatted
The command exits with the following codes:
Code |
Meaning |
|---|---|
|
Success, every file is already formatted |
|
Failure, at least one file needs reformatting |
|
Failure due to syntax errors in the files |
Note
For semantic validation, use syside check command. The format command only
checks syntax errors.
Available options
Option |
Description |
|---|---|
|
Display the help message with all available flags and short descriptions |
|
Check whether files need reformatting without editing them |
|
Suppress main output |
|
Maximum line length the formatter will target |
|
Indent using tabs instead of spaces |
|
Number of spaces per indentation level. Only applies if not using |
|
Path to a |
|
Concurrency level, 1 to 8 (default: 4) |
|
Paths or glob patterns to exclude from formatting |
|
Automatic crash report handling: |
Usage examples
Use in Git pre-commit hooks to prevent commits with bad formatting:
#!/bin/bash
# .git/hooks/pre-commit
syside format --check
For more information about Git hooks, see Git documentation.