Skip to content

Commit c75e1e3

Browse files
committed
Upgrade option
1 parent ede9c91 commit c75e1e3

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

bin/cppsm

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,40 @@
55

66
COMMAND="$CPPSM/commands/$1"
77

8-
if [ $# = 0 ] || [ ! -x "$COMMAND" ]; then
9-
BRANCH="$(git -C "$CPPSM" symbolic-ref --short HEAD)"
8+
if [ $# -ge 1 ] && [ -x "$COMMAND" ]; then
9+
shift
10+
exec "$COMMAND" "$@"
11+
fi
12+
13+
if [ "$UPGRADE" = 1 ]; then
14+
echo "Upgrading cppsm..."
15+
exec git -C "$CPPSM" pull "${GIT_QUIET[@]}" --rebase
16+
fi
1017

11-
ORIGIN="$(git -C "$CPPSM" log --pretty=oneline --abbrev-commit "..origin/$BRANCH" | sed 's#^# #g')"
12-
if [ -n "$ORIGIN" ]; then
13-
ORIGIN="$(cat << EOF
18+
BRANCH="$(git -C "$CPPSM" symbolic-ref --short HEAD)"
19+
20+
ORIGIN="$(git -C "$CPPSM" log --pretty=oneline --abbrev-commit "..origin/$BRANCH" | sed 's#^# #g')"
21+
if [ -n "$ORIGIN" ]; then
22+
ORIGIN="$(cat << EOF
1423
1524
Origin:
1625
$ORIGIN
26+
27+
Run
28+
29+
UPGRADE=1 ${0##*/}
30+
31+
to upgrade cppsm.
1732
EOF
1833
)"
19-
fi
34+
fi
2035

21-
git -C "$CPPSM" fetch --quiet
36+
git -C "$CPPSM" fetch --quiet
2237

23-
# shellcheck disable=SC2035
24-
COMMANDS="$(cd "$CPPSM/commands" && echo *)"
25-
COMMANDS="${COMMANDS// /|}"
26-
cat << EOF
38+
# shellcheck disable=SC2035
39+
COMMANDS="$(cd "$CPPSM/commands" && echo *)"
40+
COMMANDS="${COMMANDS// /|}"
41+
cat << EOF
2742
Usage: ${0##*/} [$COMMANDS]
2843
2944
Run any command with --help to see a brief description of the command.
@@ -34,8 +49,4 @@ Branch: $BRANCH
3449
$(git -C "$CPPSM" log -n 5 --pretty=oneline --abbrev-commit | sed 's#^# #g')
3550
$ORIGIN
3651
EOF
37-
exit 1
38-
fi
39-
40-
shift
41-
"$COMMAND" "$@"
52+
exit 1

0 commit comments

Comments
 (0)