Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --clang-format-version option #282

Merged
merged 1 commit into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ament_clang_format/ament_clang_format/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def main(argv=sys.argv[1:]):
help='The files or directories to check. For directories files ending '
'in %s will be considered.' %
', '.join(["'.%s'" % e for e in extensions]))
parser.add_argument(
'--clang-format-version',
help='The version of clang-format to use.')
parser.add_argument(
'--reformat',
action='store_true',
Expand Down Expand Up @@ -80,6 +83,10 @@ def main(argv=sys.argv[1:]):
'clang-format-3.4',
'clang-format-3.3',
]

if args.clang_format_version:
bin_names = ['clang-format-' + args.clang_format_version]

clang_format_bin = find_executable(bin_names)
if not clang_format_bin:
print('Could not find %s executable' %
Expand Down
15 changes: 14 additions & 1 deletion ament_clang_format/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,23 @@ How to run the check from the command line?

.. code:: sh

ament_clang_format [<path> ...]
ament_clang_format [-h] [--config path]
[--clang-format-version CLANG_FORMAT_VERSION]
[--reformat] [--xunit-file XUNIT_FILE]
[paths [paths ...]]

``paths`` are directories to recursively search for files to run clang-format
on. If no ``paths`` option is set the current directory will be used.

The ``--config`` allows you to set the path to the .clang-format file to use.

The ``--clang-format-version`` enables you to set a different version of
clang-format to use.

When using the option ``--reformat`` the proposed changes are applied in place.

The ``--xunit-file`` option is used to generate a xunit output file.


How to run the check from within a CMake ament package as part of the tests?
----------------------------------------------------------------------------
Expand Down