(gersemi) CMake 格式化工具

news2024/10/25 1:20:51

文章目录

  • 🧮介绍
  • 🧮安装
  • 🧮使用
    • 🗳️模式 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.txt

gersemi CMakeLists.txt --diff

🗳️样式配置 config

.gersemirc 文件

# 查看默认配置
gersemi --default-config
# yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/master/gersemi/configuration.schema.json

cache: 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
cachetrue false启用缓存已知格式化文件的数据,以加快执行速度。[default: cache enabled]
color如果-diff被选中,则显示diff被着色。
definitions包含自定义命令定义(函数或宏)的文件或目录。如果有自定义定义,则从stdin中获取。不需要提供未废弃的CMake原生模块的命令。https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html
indentINTEGER tabs用于缩进的空格数或用于缩进制表符的“tabs”[default: 4]
line_lengthINTEGER以字符为单位的最大行长。[default: 80]
list_expansionfavour-inlining favour-expansion[default: favour-inlining]
quiettrue false跳过将非错误消息打印到stderr。[default: false]
unsafetrue false跳过默认的完整性检查。[default: false]
warn_about_unknown_commands当启用了未知自定义命令的文件时,将会发出警告,并且结果不会被缓存。请参见README中的"Let's make a deal"部分。[default: warnings enabled]
workersINTEGER 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 when
                        there's nothing to reformat. Return 1 when some files
                        would 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 if
  it's available. This file should be placed in one of the common parent
  directories of source files. Arguments from command line can be used to
  override parts of that configuration or supply them in absence of
  configuration file.

  -l INTEGER, --line-length INTEGER
                        Maximum line length in characters. [default: 80]
  --indent (INTEGER | tabs)
                        Number of spaces used to indent or 'tabs' for
                        indenting 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 command
                        definitions (functions or macros). If only - is
                        provided custom definitions, if there are any, are
                        taken from stdin instead. Commands from not deprecated
                        CMake 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 multiple
                        lines when it's not possible to keep it formatted in
                        one line. With "favour-inlining" the list of entities
                        will be formatted in such way that sublists might
                        still be formatted into single line as long as it's
                        possible or as long as it doesn't break the "more than
                        four standalone arguments" heuristic that's mostly
                        focused on commands like `set` or `list(APPEND)`. With
                        "favour-expansion" the list of entities will be
                        formatted in such way that sublists will be completely
                        expanded once expansion becomes necessary at all.
                        [default: favour-inlining]
  -w (INTEGER | max), --workers (INTEGER | max)
                        Explicit number of workers or 'max' for maximum
                        possible number of workers on given machine used to
                        format multiple files in parallel. [default: max]
  --cache, --no-cache   Enables cache with data about files that are known to
                        be formatted to speed up execution. [default: cache
                        enabled]
  --warn-about-unknown-commands, --no-warn-about-unknown-commands
                        When enabled file which has unknown custom commands
                        will have warnings issued about that and result won't
                        be cached. See: "Let's make a deal" section in README.
                        [default: warnings enabled]

🌟交流方式

⭐交流方式⭐ |C/C++|算法|设计模式|软件架构-CSDN社区

关注我,学习更多C/C++,python,算法,软件工程,计算机知识

B站:

👨‍💻主页:天赐细莲 bilibili

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2222849.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Leetcode 最长公共前缀

java solution class Solution {public String longestCommonPrefix(String[] strs) {if(strs null || strs.length 0) {return "";}//用第一个字符串作为模板,利用indexOf()方法匹配,由右至左逐渐缩短第一个字符串的长度String prefix strs[0];for(int i 1; i …

【Java】反射概述与详解

目录 引言 一、概述 二、获取Class对象 三、反射获取构造方法 代码示例: 四、反射获取成员变量 代码示例: 五、反射获取成员方法 代码示例: 结语 引言 Java中的反射(Reflection)是一种强大的机制&#…

热门的四款PDF合并工具大比拼!!!

在现代的数字化办公环境中,PDF文件已经成为了一种重要的文件格式,用于保存和共享各种类型的文档。然而,有时候我们需要将多个PDF文件合并成一个文件,这时候就离不开好用的PDF合并工具了。选择一个好的PDF合并工具是一个长期的投资…

Python基于OpenCV的实时疲劳检测

2.检测方法 1)方法 与用于计算眨眼的传统图像处理方法不同,该方法通常涉及以下几种组合: 1、眼睛定位。 2、阈值找到眼睛的白色。 3、确定眼睛的“白色”区域是否消失了一段时间(表示眨眼)。 相反,眼睛长…

【Power Query】List.Select 筛选列表

List.Select 筛选列表 ——在列表中返回满足条件的元素 List.Select(列表,判断条件) 不是列表的可以转成列表再筛选&#xff0c;例如 Record.ToList 不同场景的判断条件参考写法 (1)单条件筛选 列表中小于50的数字 List.Select({1,99,8,98,5},each _<50) (2)多条件筛…

红黑树(Java数据结构)

前言&#xff1a; 红黑树的学习需要大家对二叉搜索树与AVL树有深刻的理解&#xff0c;如果话没有看过我对二叉搜索树与AVL树的讲解的铁子们可以先看看上一篇文章&#xff1a;二叉搜索树与AVL树(java数据结构)-CSDN博客 红黑树&#xff1a; 什么是红黑树&#xff1f; 红黑树&a…

CenterTrack算法详解

背景&#xff1a; 早期追踪器在缺乏强的低水平线索下&#xff0c;容易失败检测后跟踪的模型依赖于检测器&#xff0c;且需要一个单独的阶段匹配关联策略的时间长 简介&#xff1a; 基于点的跟踪思想&#xff0c;通过预测目标的中心点来进行跟踪&#xff0c;同时实现检测与跟…

LLM在Reranker任务上的最佳实践?A simple experiment report(with code)

知乎&#xff1a;车中草同学(已授权)链接&#xff1a;https://zhuanlan.zhihu.com/p/987727357 引言 在BERT时代&#xff0c;对于Reranker任务&#xff0c;我们使用encoder-only的BERT为基座&#xff0c;拼接query和doc输入到BERT中去&#xff0c;在使用CLS的向量通过一个MLP&a…

身份证识别JAVA+OPENCV+OCR

一、相关的地址 https://github.com/tesseract-ocr/tessdata Releases - OpenCV opencv要装好&#xff0c;我装的是4.5.3的&#xff0c;最新版的没试过。 tessdata就下载了需要用的。好像还有best和fast的版本&#xff0c;我试了一下报错&#xff0c;不知道是不是版本不支持…

华为配置 之 远程管理配置

目录 简介&#xff1a; 知识点&#xff1a; Telnet远程管理 &#xff08;1&#xff09;配置接口IP并确保R1和R2处于同一个网段 &#xff08;2&#xff09;使用password认证模式远程登录 &#xff08;3&#xff09;使用AAA认证模式远程登录 SSH远程管理 &#xff08;1&a…

基于springboot的网上服装商城推荐系统的设计与实现

基于springboot的网上服装商城推荐系统的设计与实现 开发语言&#xff1a;Java 框架&#xff1a;springboot JDK版本&#xff1a;JDK1.8 服务器&#xff1a;tomcat7 数据库&#xff1a;mysql 5.7 数据库工具&#xff1a;Navicat11 开发软件&#xff1a;idea 源码获取&#xf…

【deathStarBench】2.安装k8s集群

安装docker 通过以下命令安装docker&#xff1a; sudo yum install docker-ce-26.1.4 docker-ce-cli-26.1.4 containerd.io随后通过查看docker --version&#xff0c;可以确定是否安装的版本一样 启动docker systemctl start docker && systemctl enable docker.se…

《纳瓦尔宝典:财富和幸福指南》读书随笔

最近在罗胖的得到听书中听到一本书&#xff0c;感觉很有启发&#xff0c;书的名字叫《纳瓦尔宝典》&#xff0c;从书名上看给人的感觉应该财富知识类、鸡汤爆棚哪类。纳瓦尔&#xff0c;这个名字之前确实没有听说过&#xff0c;用一句话介绍一下&#xff0c;一个印度裔的硅谷中…

【LeetCode】修炼之路-0006-Zigzag Conversion (Z 字形变换)【python】

题目 The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: “PAHNAPLSIIGYIR” …

荣耀电脑管家-系统重装之查询设备序列号

winr输入cmd&#xff0c;再命令行中输入 wmic bios get serialnumber 如下所示

代码随想录算法训练营第六天|454四数相加II、 383赎金信、15三数之和、18四数之和

day06 1. 454四数相加II 首先定义 一个unordered_map&#xff0c;key放a和b两数之和&#xff0c;value 放a和b两数之和出现的次数。遍历大A和大B数组&#xff0c;统计两个数组元素之和&#xff0c;和出现的次数&#xff0c;放到map中。定义int变量count&#xff0c;用来统计 …

YAML格式校验API:免费工具的使用指南

YAML&#xff08;YAML Ain’t Markup Language&#xff09;是一种人类可读的数据序列化格式&#xff0c;广泛用于配置文件、数据交换等场景。由于其简洁的语法和良好的可读性&#xff0c;YAML 在开发和运维领域中越来越受到欢迎。然而&#xff0c;在使用 YAML 时&#xff0c;格…

Xcode文件默认存储位置-使用c++file保存文件默认路径以及设置为路径为当前项目路径

Xcode文件默认存储位置-使用cfile保存文件默认路径以及设置为路径为当前项目路径 1.概述 使用Xcode工具开发时候&#xff0c;遇到C调用file创建文件后&#xff0c;在当前项目中找不到文件路径。这是由于xcode会将文件保存到默认设置的路径。下面是查看文件默认存储路径和修改…

数组中的算法

目录 1.什么是数组 2.数组上的算法 2.1二分查找算法 什么是二分查找算法&#xff1f; 算法步骤 算法时间复杂度 一个问题 例题 题目分析 解题代码 2.2双指针法 什么是双指针法&#xff1f; 例题 题目分析 解题代码 1.什么是数组 数组是在一块连续的内存空间…

C++,STL 047(24.10.24)

内容 对set容器的元素进行查找与统计。 运行代码 #include <iostream> #include <set>using namespace std;void printSet(set<int> &s) {for (set<int>::iterator it s.begin(); it ! s.end(); it){cout << *it << " ";…