diff --git a/pull.sh b/pull.sh index 5473d06..b194be5 100755 --- a/pull.sh +++ b/pull.sh @@ -1,14 +1,40 @@ #!/bin/bash git_pull() { - git pull + if [[ "$1" == "-p" ]]; then + git stash + git pull + git stash pop + else + git pull + fi } git_pull_submodule() { - git submodule update --recursive --remote - git submodule foreach git checkout main - git submodule foreach git pull origin main + if [[ "$1" == "-s" ]]; then + git submodule update --recursive --remote + git submodule foreach git checkout main + git submodule foreach git pull origin main + else + echo "Usage: $0 -s" + fi } -git_pull -git_pull_submodule +while getopts "ps" opt; do + case $opt in + p) + git_pull -p + ;; + s) + git_pull_submodule -s + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + esac +done + +if [[ $# -eq 0 ]]; then + git_pull +fi diff --git a/stow.sh b/stow.sh index 88f7657..c4955cb 100755 --- a/stow.sh +++ b/stow.sh @@ -53,7 +53,7 @@ unstow() { log "All configs ustowed successfully !" } -while getopts ":suh" opt; do +while getopts "ps" opt; do case $opt in s) stow @@ -61,8 +61,13 @@ while getopts ":suh" opt; do u) unstow ;; - *) + \?) display_help + exit 1 ;; esac done + +if [[ $# -eq 0 ]]; then + display_help +fi