deskflow/scripts/lint_clang.py
Nick Bolton 9eeb1cb7ee
Introduce 'Advanced' tab to Preferences window (#7419)
* Add QML and QtQuick deps

* Keep only Qt declarative

* Fixed delcarative package name

* Use `qt6-qtdeclarative` on OpenSUSE

* Fixed warnings

* Introduce tabs for settings and make some settings easier to understand

* Further reorganization of settings UI

* Revert config.yml

* Show Qt version in config

* Remove custom font

* Improve wording of elevate privs

* Fixed window sizes and default tabs

* Save main window size and position

* Fixed slot warning

* Fixed hacky use of validators

* Make activation cancel more intuitive

* Save window state in dtor and add try-catch to prevent exceptions propagating

* Fixed consistency of fatal messages

* Improve color conssitency and add tooltip

* Clean up styles and weird layout

* Move config files to new gui lib

* Core interface integ tests

* Rename `Config` to `ConfigScopes`

* Add 'Schoeneman' to cspell

* Fixed incorrect `Config` (should be `ConfigScopes`)

* Fixed typo

* Missed a spot

* Delete accidentally re-added file

* Fixed formatting

* Add short opt

* Coverage for `AppConfig`

* Update ChangeLog

* Remove redundant includes

* Fixed date

* Remove rogue include
2024-08-01 01:13:01 +01:00

60 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python3
import lib.env as env
env.ensure_in_venv(__file__)
import argparse, sys
import lib.fs as fs
from clang_format import clang_format # type: ignore
include_files = [
"*.h",
"*.c",
"*.hpp",
"*.cpp",
]
dirs = ["src"]
def main():
"""
Cross-platform equivalent of using find and xargs with clang-format.
Lints by performing a dry run (--dry-run) which fails when formatting is needed.
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"-f",
"--format",
action="store_true",
help="In-place format all files",
)
args = parser.parse_args()
cmd_args = ["-i"] if args.format else ["--dry-run", "--Werror"]
files_recursive = fs.find_files(dirs, include_files)
if args.format:
print("Formatting files with Clang formatter:")
else:
print("Checking files with Clang formatter:")
for file in files_recursive:
print(file)
if files_recursive:
sys.argv = [""] + cmd_args + files_recursive
result = clang_format()
if result == 0:
print("Clang lint passed")
sys.exit(result)
else:
print("No files for Clang to process", file=sys.stderr)
sys.exit(0)
if __name__ == "__main__":
main()