以前は uncrustify を使っていた。
最近は clang-format というものがあるようだ。
$ brew install clang-format
A.m をフォーマットするには
$ clang-format -i A.m
.m, .h, .c をフォーマット
$ find . \( -name "*.m" -or -name "*.h" -or -name "*.c" \) -exec $(clang-format) -i \{\} \;
-style
オプションでプリセットスタイルを指定したり、設定ファイルで細かく指定したりできるみたい。
$ clang-format -h
<snip>
-dump-config - Dump configuration options to stdout and exit.
Can be used with -style option.
<snip>
-style=<string> - Coding style, currently supports:
LLVM, Google, Chromium, Mozilla, WebKit.
Use -style=file to load style configuration from
.clang-format file located in one of the parent
directories of the source file (or current
directory for stdin).
Use -style="{key: value, ...}" to set specific
parameters, e.g.:
-style="{BasedOnStyle: llvm, IndentWidth: 8}"