enhance display + add usage
This commit is contained in:
parent
ab999408d1
commit
d3a63b09bd
53
dist/bes-build
vendored
53
dist/bes-build
vendored
|
@ -9,7 +9,7 @@ bes.build(){
|
||||||
bes.echo.state $?
|
bes.echo.state $?
|
||||||
fi
|
fi
|
||||||
if [ -f "$APP_BIN" ]; then
|
if [ -f "$APP_BIN" ]; then
|
||||||
if [ "$1" = "-s" ]; then
|
if [ "$1" = "backup" ] || [ "$1" = "-b" ]; then
|
||||||
bes.echo.action "backup last build to ${Coff}dist/$(date +%y%m%d)-$APP_NAME${Coff}"
|
bes.echo.action "backup last build to ${Coff}dist/$(date +%y%m%d)-$APP_NAME${Coff}"
|
||||||
mv $APP_BIN $APP_DIR/dist/$(date +%y%m%d)-$APP_NAME
|
mv $APP_BIN $APP_DIR/dist/$(date +%y%m%d)-$APP_NAME
|
||||||
else
|
else
|
||||||
|
@ -22,23 +22,24 @@ bes.build(){
|
||||||
bes.echo.action "reading ${Coff}src/"
|
bes.echo.action "reading ${Coff}src/"
|
||||||
for entry in "$APP_DIR/src"/*.sh; do
|
for entry in "$APP_DIR/src"/*.sh; do
|
||||||
if [ "$(basename $entry)" != "main.sh" ]; then
|
if [ "$(basename $entry)" != "main.sh" ]; then
|
||||||
bes.echo " - appending ${Coff}src/$(basename $entry)"
|
bes.echo " ${Cspe}- ${Cok}appending ${Coff}src/$(basename $entry)"
|
||||||
tail -n +2 "$entry" >> "$APP_BIN"
|
tail -n +2 "$entry" >> "$APP_BIN"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ -f "$APP_DIR/src/main.sh" ]; then
|
if [ -f "$APP_DIR/src/main.sh" ]; then
|
||||||
tail -n +2 "$APP_DIR/src/main.sh" >> "$APP_BIN"
|
tail -n +2 "$APP_DIR/src/main.sh" >> "$APP_BIN"
|
||||||
bes.echo " - appending ${Coff}src/main.sh"
|
bes.echo " ${Cspe}- ${Cok}appending ${Coff}src/main.sh"
|
||||||
fi
|
fi
|
||||||
bes.echo.state 0
|
bes.echo.state 0
|
||||||
bes.echo.action "set execution mode"
|
bes.echo.action "set execution mode"
|
||||||
chmod +x $APP_BIN
|
chmod +x $APP_BIN
|
||||||
bes.echo.state $?
|
done=$?
|
||||||
|
bes.echo.state $done
|
||||||
|
bes.echo.rs $done
|
||||||
else
|
else
|
||||||
bes.echo.error "no src/ directory. exit"
|
bes.echo.error "no src/ directory. exit"
|
||||||
bes.echo.state 1
|
bes.echo.state 1
|
||||||
fi
|
fi
|
||||||
echo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BES_TERM_WIDTH=105
|
BES_TERM_WIDTH=105
|
||||||
|
@ -63,17 +64,17 @@ bes.echo(){
|
||||||
local isAction=${2:-'0'}
|
local isAction=${2:-'0'}
|
||||||
local symbol=${3:-' *'}
|
local symbol=${3:-' *'}
|
||||||
if [ ! "$BES_NOCOLOR" = 1 ]; then
|
if [ ! "$BES_NOCOLOR" = 1 ]; then
|
||||||
local c=$Cok
|
local c=" "
|
||||||
if [ -z "$isAction" ] || [ "$isAction" = 1 ]; then
|
if [ -z "$isAction" ] || [ "$isAction" = 1 ]; then
|
||||||
c=$Caction
|
c=$Caction
|
||||||
fi
|
fi
|
||||||
if [ ! "$isAction" = 0 ]; then
|
if [ ! "$isAction" = 0 ]; then
|
||||||
c=" $Citem$symbol $c"
|
c=" $Citem$symbol $c"
|
||||||
fi
|
fi
|
||||||
echo -e " $c$msg$Coff"
|
echo -e " $c$msg$Coff"
|
||||||
else
|
else
|
||||||
if [ ! "$isAction" = 0 ]; then
|
if [ ! "$isAction" = 0 ]; then
|
||||||
msg=" $symbol $msg"
|
msg=" $symbol $msg"
|
||||||
fi
|
fi
|
||||||
echo -e "$msg"
|
echo -e "$msg"
|
||||||
fi
|
fi
|
||||||
|
@ -106,6 +107,15 @@ bes.echo.state(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
bes.echo.rs(){
|
||||||
|
local rs=${1:-0}
|
||||||
|
if [ "$rs" -eq 0 ]; then
|
||||||
|
echo -e "\n ${Cdone} done ${Coff}"
|
||||||
|
else
|
||||||
|
echo -e "\n ${Cfail} failed ${Coff}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
bes.echo.error(){
|
bes.echo.error(){
|
||||||
echo -e "\n${Cerr} error : ${Coff}\n\t$1 ${Coff}\n"
|
echo -e "\n${Cerr} error : ${Coff}\n\t$1 ${Coff}\n"
|
||||||
}
|
}
|
||||||
|
@ -168,24 +178,41 @@ bes.install(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bes.usage(){
|
||||||
|
echo -e " ${Cusa}Usage :${Coff}\n
|
||||||
|
${Ccom}\tBuild current project (overwrite existing build)
|
||||||
|
${Cspe}\tbes-build ${Copt}
|
||||||
|
${Ccom}\tBuild current project and backup existing build
|
||||||
|
${Cspe}\tbes-build ${Copt}-b${Ctext}, ${Copt}backup
|
||||||
|
${Ccom}\tInstall or update bes-build on specified BINDIR directory or in /etc/local/bin directory
|
||||||
|
${Cspe}\tbes-build ${Copt}-i${Ctext}, ${Copt}install ${Copt}[ ${Ctext}BINDIR${Copt} ]
|
||||||
|
${Ccom}\tDisplay program version
|
||||||
|
${Cspe}\tbes-build ${Copt}-v${Ctext}, ${Copt}version
|
||||||
|
${Ccom}\tDisplay this help
|
||||||
|
${Cspe}\tbes-build ${Copt}-h${Ctext}, ${Copt}help"
|
||||||
|
|
||||||
|
echo -e "${Coff}"
|
||||||
|
}
|
||||||
|
|
||||||
BES_BUILD_VERSION=0.3
|
BES_BUILD_VERSION=0.3
|
||||||
APP_DIR=$(pwd)
|
APP_DIR=$(pwd)
|
||||||
APP_NAME=$(basename $(pwd))
|
APP_NAME=$(basename $(pwd))
|
||||||
APP_BIN=$APP_DIR/dist/$APP_NAME
|
APP_BIN=$APP_DIR/dist/$APP_NAME
|
||||||
|
|
||||||
bes.main(){
|
bes.main(){
|
||||||
if [ "$1" = "version" ]; then
|
if [ "$1" = "version" ] || [ "$1" = "-v" ]; then
|
||||||
echo $BES_BUILD_VERSION
|
echo $BES_BUILD_VERSION
|
||||||
else
|
else
|
||||||
bes.title 'bes-build' $BES_BUILD_VERSION
|
bes.title 'bes-build' $BES_BUILD_VERSION
|
||||||
echo
|
echo
|
||||||
if [ "$1" = "install" ]; then
|
if [ "$1" = "install" ] || [ "$1" = "-i" ]; then
|
||||||
bes.install $2
|
bes.install "$2"
|
||||||
elif [ -z "$1" ] || [ "$1" = "-s" ]; then
|
elif [ "$1" = "help" ] || [ "$1" = "-h" ]; then
|
||||||
|
bes.usage
|
||||||
|
elif [ -z "$1" ] || [ "$1" = "backup" ] || [ "$1" = "-b" ]; then
|
||||||
bes.build "$1"
|
bes.build "$1"
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
bes.main $*
|
bes.main $*
|
||||||
|
|
11
src/build.sh
11
src/build.sh
|
@ -9,7 +9,7 @@ bes.build(){
|
||||||
bes.echo.state $?
|
bes.echo.state $?
|
||||||
fi
|
fi
|
||||||
if [ -f "$APP_BIN" ]; then
|
if [ -f "$APP_BIN" ]; then
|
||||||
if [ "$1" = "-s" ]; then
|
if [ "$1" = "backup" ] || [ "$1" = "-b" ]; then
|
||||||
bes.echo.action "backup last build to ${Coff}dist/$(date +%y%m%d)-$APP_NAME${Coff}"
|
bes.echo.action "backup last build to ${Coff}dist/$(date +%y%m%d)-$APP_NAME${Coff}"
|
||||||
mv $APP_BIN $APP_DIR/dist/$(date +%y%m%d)-$APP_NAME
|
mv $APP_BIN $APP_DIR/dist/$(date +%y%m%d)-$APP_NAME
|
||||||
else
|
else
|
||||||
|
@ -22,21 +22,22 @@ bes.build(){
|
||||||
bes.echo.action "reading ${Coff}src/"
|
bes.echo.action "reading ${Coff}src/"
|
||||||
for entry in "$APP_DIR/src"/*.sh; do
|
for entry in "$APP_DIR/src"/*.sh; do
|
||||||
if [ "$(basename $entry)" != "main.sh" ]; then
|
if [ "$(basename $entry)" != "main.sh" ]; then
|
||||||
bes.echo " - appending ${Coff}src/$(basename $entry)"
|
bes.echo " ${Cspe}- ${Cok}appending ${Coff}src/$(basename $entry)"
|
||||||
tail -n +2 "$entry" >> "$APP_BIN"
|
tail -n +2 "$entry" >> "$APP_BIN"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ -f "$APP_DIR/src/main.sh" ]; then
|
if [ -f "$APP_DIR/src/main.sh" ]; then
|
||||||
tail -n +2 "$APP_DIR/src/main.sh" >> "$APP_BIN"
|
tail -n +2 "$APP_DIR/src/main.sh" >> "$APP_BIN"
|
||||||
bes.echo " - appending ${Coff}src/main.sh"
|
bes.echo " ${Cspe}- ${Cok}appending ${Coff}src/main.sh"
|
||||||
fi
|
fi
|
||||||
bes.echo.state 0
|
bes.echo.state 0
|
||||||
bes.echo.action "set execution mode"
|
bes.echo.action "set execution mode"
|
||||||
chmod +x $APP_BIN
|
chmod +x $APP_BIN
|
||||||
bes.echo.state $?
|
done=$?
|
||||||
|
bes.echo.state $done
|
||||||
|
bes.echo.rs $done
|
||||||
else
|
else
|
||||||
bes.echo.error "no src/ directory. exit"
|
bes.echo.error "no src/ directory. exit"
|
||||||
bes.echo.state 1
|
bes.echo.state 1
|
||||||
fi
|
fi
|
||||||
echo
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,17 +22,17 @@ bes.echo(){
|
||||||
local isAction=${2:-'0'}
|
local isAction=${2:-'0'}
|
||||||
local symbol=${3:-' *'}
|
local symbol=${3:-' *'}
|
||||||
if [ ! "$BES_NOCOLOR" = 1 ]; then
|
if [ ! "$BES_NOCOLOR" = 1 ]; then
|
||||||
local c=$Cok
|
local c=" "
|
||||||
if [ -z "$isAction" ] || [ "$isAction" = 1 ]; then
|
if [ -z "$isAction" ] || [ "$isAction" = 1 ]; then
|
||||||
c=$Caction
|
c=$Caction
|
||||||
fi
|
fi
|
||||||
if [ ! "$isAction" = 0 ]; then
|
if [ ! "$isAction" = 0 ]; then
|
||||||
c=" $Citem$symbol $c"
|
c=" $Citem$symbol $c"
|
||||||
fi
|
fi
|
||||||
echo -e " $c$msg$Coff"
|
echo -e " $c$msg$Coff"
|
||||||
else
|
else
|
||||||
if [ ! "$isAction" = 0 ]; then
|
if [ ! "$isAction" = 0 ]; then
|
||||||
msg=" $symbol $msg"
|
msg=" $symbol $msg"
|
||||||
fi
|
fi
|
||||||
echo -e "$msg"
|
echo -e "$msg"
|
||||||
fi
|
fi
|
||||||
|
@ -65,6 +65,15 @@ bes.echo.state(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
bes.echo.rs(){
|
||||||
|
local rs=${1:-0}
|
||||||
|
if [ "$rs" -eq 0 ]; then
|
||||||
|
echo -e "\n ${Cdone} done ${Coff}"
|
||||||
|
else
|
||||||
|
echo -e "\n ${Cfail} failed ${Coff}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
bes.echo.error(){
|
bes.echo.error(){
|
||||||
echo -e "\n${Cerr} error : ${Coff}\n\t$1 ${Coff}\n"
|
echo -e "\n${Cerr} error : ${Coff}\n\t$1 ${Coff}\n"
|
||||||
}
|
}
|
||||||
|
|
11
src/main.sh
11
src/main.sh
|
@ -6,18 +6,19 @@ BES_BUILD_VERSION=0.3
|
||||||
APP_BIN=$APP_DIR/dist/$APP_NAME
|
APP_BIN=$APP_DIR/dist/$APP_NAME
|
||||||
|
|
||||||
bes.main(){
|
bes.main(){
|
||||||
if [ "$1" = "version" ]; then
|
if [ "$1" = "version" ] || [ "$1" = "-v" ]; then
|
||||||
echo $BES_BUILD_VERSION
|
echo $BES_BUILD_VERSION
|
||||||
else
|
else
|
||||||
bes.title 'bes-build' $BES_BUILD_VERSION
|
bes.title 'bes-build' $BES_BUILD_VERSION
|
||||||
echo
|
echo
|
||||||
if [ "$1" = "install" ]; then
|
if [ "$1" = "install" ] || [ "$1" = "-i" ]; then
|
||||||
bes.install $2
|
bes.install "$2"
|
||||||
elif [ -z "$1" ] || [ "$1" = "-s" ]; then
|
elif [ "$1" = "help" ] || [ "$1" = "-h" ]; then
|
||||||
|
bes.usage
|
||||||
|
elif [ -z "$1" ] || [ "$1" = "backup" ] || [ "$1" = "-b" ]; then
|
||||||
bes.build "$1"
|
bes.build "$1"
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
bes.main $*
|
bes.main $*
|
||||||
|
|
17
src/usage.sh
Normal file
17
src/usage.sh
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
bes.usage(){
|
||||||
|
echo -e " ${Cusa}Usage :${Coff}\n
|
||||||
|
${Ccom}\tBuild current project (overwrite existing build)
|
||||||
|
${Cspe}\tbes-build ${Copt}
|
||||||
|
${Ccom}\tBuild current project and backup existing build
|
||||||
|
${Cspe}\tbes-build ${Copt}-b${Ctext}, ${Copt}backup
|
||||||
|
${Ccom}\tInstall or update bes-build on specified BINDIR directory or in /etc/local/bin directory
|
||||||
|
${Cspe}\tbes-build ${Copt}-i${Ctext}, ${Copt}install ${Copt}[ ${Ctext}BINDIR${Copt} ]
|
||||||
|
${Ccom}\tDisplay program version
|
||||||
|
${Cspe}\tbes-build ${Copt}-v${Ctext}, ${Copt}version
|
||||||
|
${Ccom}\tDisplay this help
|
||||||
|
${Cspe}\tbes-build ${Copt}-h${Ctext}, ${Copt}help"
|
||||||
|
|
||||||
|
echo -e "${Coff}"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user