Skip to content

Commit

Permalink
Add clang-format-version option to ament_clang_format
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Weaver <[email protected]>
  • Loading branch information
tylerjw committed Jan 19, 2021
1 parent 8bf194a commit 61c84f7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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

0 comments on commit 61c84f7

Please sign in to comment.