feat: add script that uses the clang-format
executable to format all project files
#817
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#614 This PR is to add
format_project.py
script that uses theclang-format
executable to format all project files according to the provided.clang-format
configuration. It does the following actions:Prerequisites
clang-format
executable installed.clang-format
configuration file presentInstalling clang-format
On macOS:
brew install clang-format
On Ubuntu/Debian:
sudo apt-get install clang-format
On Windows:
Usage
Basic Usage
python format_project.py /project/path
Advanced Usage
python format_project.py /project/path --clang-format /clang-format/path --config /.clang-format/path --extensions .cpp .hpp .h
clang-format
executable on your system.Command-line Arguments
-h
or--help
to view usage and see optionsdirectory
(required): The root directory of your project to search for files--clang-format
(optional): Path to the clang-format executable (default: "clang-format")--config
(optional): Path to the .clang-format configuration file (default: ".clang-format")--extensions
(optional): File extensions to format (default:.cpp .hpp .h .c
)How you can determine clang-format path:
/usr/local/bin/clang-format
or/opt/homebrew/bin/clang-format
/usr/bin/clang-format
C:\Program Files\LLVM\bin\clang-format.exe
which clang-format
where clang-format