Skip to content
Snippets Groups Projects
Commit d16ee4fa authored by Simon Oehrl's avatar Simon Oehrl
Browse files

Add main menu

parent 973353ce
Branches
No related tags found
No related merge requests found
#!/bin/sh
if [ ! -f "update.txt" ]
then
remote_branch=$(git rev-parse --abbrev-ref @{u})
function initial_setup() {
clear
if [[ "$remote_branch" != "origin/"* ]]
echo "The setup will now delete all branches and remotes and create a default develop and master branch. Continue? [Y/n]"
read cont
if [ $cont == "y" ] || [ $cont == "Y" ] || [ $cont == "" ]
then
echo "This script can only handle remotes named origin!"
exit -1
fi
remote_branch=${remote_branch#"origin/"}
repository_url=$(git remote get-url origin)
echo "$repository_url"
echo "$repository_url" >> update.txt
echo "$remote_branch" >> update.txt
fi
current_branch=$(git rev-parse --abbrev-ref HEAD)
branches_to_delete=$(git for-each-ref --format='%(refname:short)' refs/heads/)
......@@ -36,11 +24,12 @@ then
git branch -d "$current_branch"
fi
git remote remove origin
git add .
git commit -m "Initial commit"
git branch master
git remote | xargs -n1 git remote remove
echo "Enter URL of the project's git repository (Leave empty to skip this step):"
read new_remote
......@@ -53,5 +42,69 @@ then
git push -u origin master
git checkout develop
fi
echo "Done!"
else
echo "Skipping setup. Press enter to continue"
read temp
fi
}
function manage_plugins() {
echo "Hello!"
}
function show_main_menu() {
selection=0
exit=false
while [ $exit = false ]
do
clear
echo "Select Task:"
echo "[Arrow Up/Down] Change Selection"
echo "[Enter] Select"
echo ""
items=("InitialSetup" "ManagePlugins" "Exit")
for i in ${!items[@]}
do
if [ $i == $selection ]
then
printf "\e[7m* "
else
printf " "
fi
echo "${items[$i]}"
if [ $i == $selection ]
then
printf "\e[0m"
fi
done
IFS=''
escape_char=$(printf "\u1b")
read -rsn1 mode # get 1 character
if [[ $mode == $escape_char ]]; then
read -rsn2 mode # read 2 more chars
fi
case $mode in
"") exit=true ;;
"[A") if [ "$selection" -gt "0" ]; then let selection-=1; fi ;;
"[B") if [ "$selection" -lt "3" ]; then let selection+=1; fi ;;
*) >&2;;
esac
done
case $selection in
0) initial_setup; show_main_menu ;;
1) manage_plugins; show_main_menu ;;
2) ;;
*) >&2;;
esac
}
show_main_menu
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment