小黄瓜语言格式
reformat-gherkin的Python项目详细描述
重新格式化小黄瓜
目录
关于
此工具是用于小黄瓜文件的格式化程序。无论项目和作者如何,它都确保了外观的一致性。
reformat-gherkin
可以用作命令行工具,也可以用作pre-commit
挂钩。
开始
这些说明将为您在本地计算机上启动和运行项目的副本,以便进行开发和测试。
先决条件
安装
克隆此存储库
git clone https://github.com/ducminh-phan/reformat-gherkin.git
安装依赖项
cd reformat-gherkin poetry install
用法
Usage: reformat-gherkin [OPTIONS] [SRC]...
Reformat the given Gherkin files and all files in the given directories
recursively.
Options:
--check Don't write the files back, just return the
status. Return code 0 means nothing would
change. Return code 1 means some files would
be reformatted. Return code 123 means there
was an internal error.
-a, --alignment [left|right] Specify the alignment of step keywords (Given,
When, Then,...). If specified, all statements
after step keywords are left-aligned, spaces
are inserted before/after the keywords to
right/left align them. By default, step
keywords are left-aligned, and there is a
single space between the step keyword and the
statement.
-n, --newline [LF|CRLF] Specify the line separators when formatting
files inplace. If not specified, line
separators are preserved.
--fast / --safe If --fast given, skip the sanity checks of
file contents. [default: --safe]
--config FILE Read configuration from FILE.
--version Show the version and exit.
--help Show this message and exit.
配置文件
该工具能够从.reformat-gherkin.yaml
文件中读取其命令行选项的特定于项目的默认值。
默认情况下,reformat-gherkin
从命令行上传递的所有文件和目录的公共基目录开始查找配置文件。如果不存在,则在父目录中查找。当它找到文件、或.git目录、或.hg目录或文件系统的根目录(以先到者为准)时,将停止查找。
配置文件示例
check:Falsealignment:left
预提交挂钩
安装了pre-commit之后,将其添加到存储库中的.pre-commit-config.yaml
:
repos:
- repo: https://github.com/ducminh-phan/reformat-gherkin
rev: stable
hooks:
- id: reformat-gherkin
然后运行pre-commit install
就可以开始了。
致谢
这个项目的灵感来自black。有些函数取自black
的源代码。