1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00
ScreenPlay/Tools/cmake_format.py

30 lines
887 B
Python
Raw Normal View History

2021-05-16 13:09:32 +02:00
import os
import argparse
from format_util import find_files
from format_util import check_git_exit
from format_util import execute_threaded
2022-11-02 12:15:34 +01:00
from sys import stdout
stdout.reconfigure(encoding='utf-8')
2021-05-16 13:09:32 +02:00
def format_file_function(file):
executable = "cmake-format"
if os.name == 'nt':
executable = "cmake-format.exe"
os.system(" %s -c ../.cmake-format.py -i %s" % (executable, file))
print("Format: ", file)
def main(git_staged_only=False):
file_list = find_files(('CMakeLists.txt'), "", git_staged_only)
execute_threaded(file_list, format_file_function)
if not git_staged_only:
check_git_exit("CMake Format")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-s', action="store_true", dest="stage_only",
default=False)
args = parser.parse_args()
main(args.stage_only)