Skip to content

Commit 28b4171

Browse files
author
杨利兵
committed
添加安装命令
1 parent 1d9dbd2 commit 28b4171

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

cg

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
5+
# For more information about the cg.jar, please vist the following page:
6+
# https://github.com/excel-code-generator/code-generator
7+
CG_PATH=$HOME/.cg/bin/cg.jar
8+
9+
if [ ! -f $CG_PATH ];then
10+
echo "`tput setaf 1`ERROR: The file \"$CG_PATH\" does not exist.`tput sgr0`"
11+
echo
12+
echo "For more information about the cg.jar, please vist the following page:"
13+
echo "`tput setaf 4`https://github.com/excel-code-generator/code-generator `tput sgr0`"
14+
exit 1
15+
fi
16+
17+
do_update () {
18+
echo "updatet "
19+
curl https://raw.githubusercontent.com/excel-code-generator/code-generator/master/LICENSE|bash
20+
}
21+
22+
if [ "update" = "$1" ];then
23+
echo update code generator
24+
do_update
25+
exit 0
26+
fi
27+
28+
java -jar $CG_PATH $@

install.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env sh
2+
set -e
3+
4+
# Always download the latest version
5+
# For more information about the cg.jar, please vist the following page:
6+
# https://github.com/excel-code-generator/code-generator
7+
8+
CG_PATH="excel-code-generator/code-generator"
9+
BASE_PATH="https://github.com/$CG_PATH"
10+
RAW_PATH="https://raw.githubusercontent.com/$CG_PATH"
11+
12+
# latest version
13+
echo "Get the latest version"
14+
VER=`curl --silent "$BASE_PATH/releases/latest" | sed 's#.*tag/\(.*\)".*#\1#'`
15+
echo "Latest version: $VER"
16+
17+
# download
18+
SH_FILE="$RAW_PATH/$VER/LICENSE"
19+
JAR_FILE="$BASE_PATH/releases/download/$VER/cg.jar"
20+
21+
download_file() {
22+
echo "Download file `tput setaf 4`$2`tput sgr0`"
23+
curl -Lfo /tmp/$1 $2
24+
}
25+
echo "Downloading..."
26+
download_file cg $SH_FILE
27+
download_file cg.jar $JAR_FILE
28+
29+
echo "Download success."
30+
31+
# move file
32+
CG_DIR=$HOME/.cg/bin
33+
mkdir -p $CG_DIR
34+
35+
chmod +x /tmp/cg
36+
mv /tmp/cg /usr/local/bin/
37+
mv /tmp/cg.jar $CG_DIR/
38+
39+
echo "Install success!"
40+
cg -v

0 commit comments

Comments
 (0)