Skip to content

Commit 3651b22

Browse files
committed
Add command upgrade to upgrade oo
1 parent 354c9cf commit 3651b22

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Commands:
9393
oo bin [<version>] Show go binary path by version
9494
oo build [<version>] Build go by version
9595
oo env Output current go env
96+
oo upgrade Upgrade oo to latest version
9697

9798
Options:
9899
-v, --version Output oo's version

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.5

bin/oo

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/bash
22

3-
VERSION='0.0.4'
4-
53
#
64
# Settings
75
#
@@ -20,6 +18,8 @@ VERSIONS_DIR=${ROOT_DIR}/versions
2018
GOROOT_DIR=${ROOT_DIR}/go
2119
GOBIN_PATH=${GOROOT_DIR}/bin/go
2220

21+
VERSION=$(cat ${ROOT_DIR}/VERSION)
22+
2323
#
2424
# Help
2525
#
@@ -39,6 +39,7 @@ Commands:
3939
oo bin [<version>] Show go binary path by version
4040
oo build [<version>] Build go by version
4141
oo env Output current go env
42+
oo upgrade Upgrade oo to latest version
4243
4344
Options:
4445
-v, --version Output oo's version
@@ -249,6 +250,15 @@ env() {
249250
exec "${GOBIN_PATH}" env
250251
}
251252

253+
#
254+
# Upgrade oo
255+
#
256+
upgrade() {
257+
command -v git > /dev/null 2>&1 || abort 'git not installed'
258+
cd ${ROOT_DIR} && git pull git://github.com/hit9/oo.git master
259+
printf '=> %s\n' $(cat ${ROOT_DIR}/VERSION)
260+
}
261+
252262
#
253263
# Main
254264
#
@@ -267,6 +277,7 @@ else
267277
bin) bin $2 ;;
268278
build) build $2 ;;
269279
env) env ;;
280+
upgrade) upgrade ;;
270281
*) use $1 ;;
271282
esac
272283
fi

0 commit comments

Comments
 (0)