Hello Llvm Community,
I would like to present you a small clang-format proposal.
I want to propose a '-r' option, with which, clang-format will search for files, which will match regex[s] (passed as a command line arguments, like normal files), down in the directories tree.
What motivates such changes is more user-friendly clang-format. Now when user want to do format all files in the current location and subdirectories,, he need to write some scripts/use bash magic or rely on that, that shell itself will expand regex into file names. On Windows, it's even harder. Sample clang-format call, for c++ header and source files, would look e.g. like this:
clang-format -i -r .\.cpp$ .\.hpp$
This patch provides strict regex matching, so such call won't work:
'clang-format -i -r *.cpp'
Next thing to implement could be some kind of 'easy regexs' or so, which would accept '*.cpp', but IMHO this isn't in the scope of this patch, so I didn't implement it.
I didn't write any test or so. Before, I wanted to write this mail and get feedback if -r option is even a thing and you will like it. After your acceptance (if it'll be an acceptance), I'll write tests, update documentation etc.
If you have questions/comments/accepts/rejects feel free (:
P.S. I don't know why there is so many changes in lines that I didn't even touched. I've just ran clang-format -i -style=file to format this file.
I could imagine the path you supplying being just a directory . or ../../include/Format as much as a wild card, once in that directory I might want to you clang-format all the file types clang-format supports or just a few? how could we do that?
it would be nice if we could supply multiple directories on the command line
I wonder if the wild card should act more like --gtest_filter
or find's -iregex?