Linux command
snakefmt 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Format Snakefile
snakefmt [Snakefile]
Check formatting
snakefmt --check [Snakefile]
Format directory
snakefmt [workflow/]
Show diff
snakefmt --diff [Snakefile]
Set line length
snakefmt -l [100] [Snakefile]
Format stdin
cat [Snakefile] | snakefmt -
Verbose output
snakefmt -v [Snakefile]
说明
snakefmt is an opinionated code formatter for Snakemake workflow files. It enforces a consistent style across Snakefiles and associated rules files, handling both standard Python syntax and Snakemake-specific extensions like rule, checkpoint, and module blocks. The formatter is built on top of Python's black formatter, using the same default line length of 88 characters and similar formatting philosophy. It understands Snakemake's domain-specific syntax, correctly formatting rule parameters like input, output, params, and shell while preserving semantic meaning. Check mode (--check) verifies formatting without modifying files, returning a non-zero exit code if changes are needed, which is useful for CI pipelines. Diff mode (--diff) previews the exact changes that would be made before committing to them.
参数
- --check
- Check only, no changes.
- --diff
- Show changes.
- -l, --line-length _N_
- Max line length.
- -v, --verbose
- Verbose output.
- --include _PATTERN_
- Regular expression for files to include when formatting directories.
- --exclude _PATTERN_
- Regular expression for files to exclude when formatting directories.
- --config _FILE_
- Read configuration from a pyproject.toml or .editorconfig file.
- -
- Read from stdin.
FAQ
What is the snakefmt command used for?
snakefmt is an opinionated code formatter for Snakemake workflow files. It enforces a consistent style across Snakefiles and associated rules files, handling both standard Python syntax and Snakemake-specific extensions like rule, checkpoint, and module blocks. The formatter is built on top of Python's black formatter, using the same default line length of 88 characters and similar formatting philosophy. It understands Snakemake's domain-specific syntax, correctly formatting rule parameters like input, output, params, and shell while preserving semantic meaning. Check mode (--check) verifies formatting without modifying files, returning a non-zero exit code if changes are needed, which is useful for CI pipelines. Diff mode (--diff) previews the exact changes that would be made before committing to them.
How do I run a basic snakefmt example?
Run `snakefmt [Snakefile]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --check do in snakefmt?
Check only, no changes.