Skip to content

Commit 190988d

Browse files
committed
Added format command
1 parent 418a6b5 commit 190988d

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ emacs internals/program/hello.cpp &
6464
cppsm test-watch
6565
```
6666

67+
Format project files inplace:
68+
69+
```bash
70+
cppsm format
71+
```
72+
6773
Clone an existing project:
6874

6975
```bash

bash_completion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ __cppsm_complete() {
1010
case "$PREVIOUS" in
1111
cppsm)
1212
# shellcheck disable=SC2207
13-
COMPREPLY=($(compgen -W "add build build-watch clone hello init list remove setup test test-watch update-all" -- "$CURRENT"))
13+
COMPREPLY=($(compgen -W "add build build-watch clone format hello init list remove setup test test-watch update-all" -- "$CURRENT"))
1414
;;
1515
add)
1616
# shellcheck disable=SC2207

commands/format

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash -e
2+
3+
# shellcheck source=.settings
4+
. "${BASH_SOURCE%/*}/.settings"
5+
6+
if [ "$#" -ne 0 ] || [ ! -d .git ] ; then
7+
CMD="${0##*/}"
8+
cat << EOF
9+
Usage: $CMD
10+
11+
Formats project files inplace using
12+
- clang-format ( https://clang.llvm.org/docs/ClangFormat.html ), and
13+
- prettier ( https://prettier.io/ ).
14+
EOF
15+
exit 1
16+
fi
17+
18+
for ROOT in provides internals ; do
19+
find $ROOT -name '*.md' -print0 | xargs -0 prettier --write --
20+
for SUFFIX in cpp hpp ; do
21+
find $ROOT -name "*.$SUFFIX" -print0 | xargs -0 clang-format -i --
22+
done
23+
done
24+
25+
find . -name '*.md' -maxdepth 1 -print0 | xargs -0 prettier --write --

commands/hello

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ cat << EOF > internals/testing/message_test.cpp
5656
5757
using namespace testing_v1;
5858
59-
auto hello_test = test([]() {
60-
verify("Hello, there!" == message_v1::hello("there"));
61-
});
59+
auto hello_test =
60+
test([]() { verify("Hello, there!" == message_v1::hello("there")); });
6261
EOF
6362

6463
mkdir -p internals/program

test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ git init
88
cppsm init
99
cppsm hello
1010

11+
git add internals provides
12+
git config --global user.email "[email protected]"
13+
git config --global user.name "CI script"
14+
git commit -m Initial
15+
1116
.cppsm/travis-ci
1217

1318
git submodule add -b v1 https://github.com/per-framework/dumpster.cpp.git equipment/dumpster.cpp/v1

0 commit comments

Comments
 (0)