refactor argument parsing

This commit is contained in:
Frieder Schlesier 2018-06-02 17:17:16 +02:00
parent 34499ac38c
commit a038dc96be
1 changed files with 32 additions and 31 deletions

View File

@ -2,7 +2,7 @@
set -e set -e
# install.sh # install.sh
# This script installs my basic setup for a debian laptop # This script installs my basic setup for a debian machine
USERNAME=fschl USERNAME=fschl
@ -68,7 +68,6 @@ base_applications() {
} }
install_server_base() { install_server_base() {
echo "update and installing server base tools..." echo "update and installing server base tools..."
DEBIAN_FRONTEND=noninteractive DEBIAN_FRONTEND=noninteractive
@ -244,7 +243,6 @@ install_golang() {
go get golang.org/x/tools/cmd/goimports go get golang.org/x/tools/cmd/goimports
go get golang.org/x/tools/cmd/gorename go get golang.org/x/tools/cmd/gorename
go get github.com/FiloSottile/vendorcheck
go get github.com/nsf/gocode go get github.com/nsf/gocode
#done #done
) )
@ -310,36 +308,39 @@ main() {
local cmd=$1 local cmd=$1
if [[ -z "$cmd" ]]; then if [[ -z "$cmd" ]]; then
echo "Usage: \n base | desktop | server | dotfiles | compose | go" echo "Usage: \n base | desktop | server | dotfiles | update-docker | go"
fi fi
# TODO: refactor to case case "$cmd" in
if [[ $cmd == "compose" ]]; then base)
install_compose
elif [[ $cmd == "base" ]]; then
apt_sources apt_sources
base_applications base_applications
install_docker install_docker
sudo groupadd docker
sudo adduser -aG docker "$USERNAME"
install_compose install_compose
elif [[ $cmd == "docker" ]]; then ;;
install_docker dotfiles)
elif [[ $cmd == "dotfiles" ]]; then
get_dotfiles get_dotfiles
elif [[ $cmd == "go" ]]; then ;;
install_golang server)
elif [[ $cmd == "goprojects" ]]; then
get_public_go_projects
elif [[ $cmd == "server" ]]; then
install_server_base install_server_base
elif [[ $cmd == "desktop" ]]; then ;;
desktop)
install_i3 install_i3
if [ -f "./get_private_stuff.sh" ]; then if [ -f "./get_private_stuff.sh" ]; then
source get_private_stuff.sh source get_private_stuff.sh
fi fi
fi ;;
update-docker)
# install_docker
install_compose
;;
go)
install_golang
get_public_go_projects
;;
esac
} }
main "$@" main "$@"