文章目录
- 🧮介绍
- 🧮安装
- 🧮使用
- 🗳️模式 modes
- 🗳️样式配置 config
- ⭐END
- 🌟help
- 🌟交流方式
🧮介绍
BlankSpruce/gersemi: A formatter to make your CMake code the real treasure
A formatter to make your CMake code the real treasure.
一个格式化程序,使您的CMake代码真正的财富。
Gersemi - Wikipedia
Gersemi (Old Norse “treasure”) is the daughter of the fertility-goddess Freyja in Norse mythology.She could be the same figure as Hnoss, another daughter of Freyja.
Gersemi(古挪威语“宝藏”)是挪威神话中生育女神Freyja的女儿。她可能和弗雷娅的另一个女儿赫诺斯一样。
🧮安装
# 查询包
pip_search gersemi# 安装
pip install gersemi# 卸载
pip uninstall gersemi
贴图
🧮使用
最简单直接的使用
直接指定目标的 cmake 文件。
gersemi CMakeLists.txt
🗳️模式 modes
mode | 含义 |
---|---|
-c, --check | 检查文件是否需要重新格式化。当没有重新格式化的时候返回0。当一些文件被重新格式化时返回1。 |
-i, --in-plac | 原地格式化文件。 |
–diff | 为每个格式化文件展示不同点。 |
–default-config | 生成默认的配置文件 名为.gersemirc 文件 |
–version | 展示版本 |
-h, --help | 展示帮助信息并退出 |
gersemi -i CMakeLists.txtgersemi CMakeLists.txt --diff
🗳️样式配置 config
.gersemirc 文件
# 查看默认配置
gersemi --default-config
# yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/master/gersemi/configuration.schema.jsoncache: true
color: false
definitions: []
indent: 4
line_length: 80
list_expansion: favour-inlining
quiet: false
unsafe: false
warn_about_unknown_commands: true
workers: max
这个部分 help 信息说明的不全,当然也可能是笔者没有找到对应的使用说明文档在哪。
属性 | 可选项 | 含义 | other |
---|---|---|---|
cache | true false | 启用缓存已知格式化文件的数据,以加快执行速度。 | [default: cache enabled] |
color | 如果-diff被选中,则显示diff被着色。 | ||
definitions | 包含自定义命令定义(函数或宏)的文件或目录。如果有自定义定义,则从stdin中获取。不需要提供未废弃的CMake原生模块的命令。 | https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html | |
indent | INTEGER tabs | 用于缩进的空格数或用于缩进制表符的“tabs” | [default: 4] |
line_length | INTEGER | 以字符为单位的最大行长。 | [default: 80] |
list_expansion | favour-inlining favour-expansion | [default: favour-inlining] | |
quiet | true false | 跳过将非错误消息打印到stderr。 | [default: false] |
unsafe | true false | 跳过默认的完整性检查。 | [default: false] |
warn_about_unknown_commands | 当启用了未知自定义命令的文件时,将会发出警告,并且结果不会被缓存。请参见README中的"Let's make a deal" 部分。 | [default: warnings enabled] | |
workers | INTEGER max | 明确的worker数量或max 用于给定机器上并行格式化多个文件的最大可能worker数量。 | [default: max] |
注意:
color 经笔者测试无论 true | false 还是直接写颜色或者 rgb 君无效。
还有很多别的规则,还是参照
README.md
为好。其实感觉很多功能都没实现。
⭐END
🌟help
usage: gersemi [-c] [-i] [--diff] [--default-config] [--version] [-h][-l INTEGER] [--indent (INTEGER | tabs)] [--unsafe] [-q][--color] [--definitions src [src ...]][--list-expansion {favour-inlining,favour-expansion}][-w (INTEGER | max)] [--cache] [--warn-about-unknown-commands][src ...]A formatter to make your CMake code the real treasure.positional arguments:src File or directory to format. If only `-` is provided,input is taken from stdin instead.modes:-c, --check Check if files require reformatting. Return 0 whenthere's nothing to reformat. Return 1 when some fileswould be reformatted.-i, --in-place Format files in-place.--diff Show diff on stdout for each formatted file instead.--default-config Generate default .gersemirc configuration file.--version Show version.-h, --help Show this help message and exit.configuration:By default configuration is loaded from YAML formatted .gersemirc file ifit's available. This file should be placed in one of the common parentdirectories of source files. Arguments from command line can be used tooverride parts of that configuration or supply them in absence ofconfiguration file.-l INTEGER, --line-length INTEGERMaximum line length in characters. [default: 80]--indent (INTEGER | tabs)Number of spaces used to indent or 'tabs' forindenting with tabs [default: 4]--unsafe Skip default sanity checks.-q, --quiet Skip printing non-error messages to stderr.--color If --diff is selected showed diff is colorized.--definitions src [src ...]Files or directories containing custom commanddefinitions (functions or macros). If only - isprovided custom definitions, if there are any, aretaken from stdin instead. Commands from not deprecatedCMake native modules don't have to be provided. See:https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html--list-expansion {favour-inlining,favour-expansion}Switch controls how code is expanded into multiplelines when it's not possible to keep it formatted inone line. With "favour-inlining" the list of entitieswill be formatted in such way that sublists mightstill be formatted into single line as long as it'spossible or as long as it doesn't break the "more thanfour standalone arguments" heuristic that's mostlyfocused on commands like `set` or `list(APPEND)`. With"favour-expansion" the list of entities will beformatted in such way that sublists will be completelyexpanded once expansion becomes necessary at all.[default: favour-inlining]-w (INTEGER | max), --workers (INTEGER | max)Explicit number of workers or 'max' for maximumpossible number of workers on given machine used toformat multiple files in parallel. [default: max]--cache, --no-cache Enables cache with data about files that are known tobe formatted to speed up execution. [default: cacheenabled]--warn-about-unknown-commands, --no-warn-about-unknown-commandsWhen enabled file which has unknown custom commandswill have warnings issued about that and result won'tbe cached. See: "Let's make a deal" section in README.[default: warnings enabled]
🌟交流方式
⭐交流方式⭐ |C/C++|算法|设计模式|软件架构-CSDN社区
关注我,学习更多C/C++,python,算法,软件工程,计算机知识
B站:
👨💻主页:天赐细莲 bilibili