mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 06:17:00 +08:00
common.sh: argparser supports -d/--dev and -D/--dry-run
This commit is contained in:
parent
3c10ebfaeb
commit
5f27592fb4
|
@ -319,7 +319,6 @@ for i in ${GOT_OPTS[@]}; do
|
|||
case $i in
|
||||
-i ) FUNC=install ;;
|
||||
-r ) FUNC=uninstall ;;
|
||||
-d|--dev ) export DFS_DEV=1; set -x ;;
|
||||
-a|--auto ) INSTALL_DEP=1 ;;
|
||||
-s|--secure ) export DFS_DEV=0 ;;
|
||||
-H|--hist|--history ) store_hist=1 ;;
|
||||
|
|
|
@ -115,7 +115,7 @@ eval_or_echo() {
|
|||
fi
|
||||
}
|
||||
|
||||
# ssh
|
||||
# ssh series
|
||||
prepare_ssh_cmd() {
|
||||
local ssh_bin="${1:-ssh}"
|
||||
if [[ "$ssh_bin" == "scp" || "$ssh_bin" == "sftp" ]]; then
|
||||
|
@ -126,6 +126,7 @@ prepare_ssh_cmd() {
|
|||
echo "$ssh_bin ${PORT:+$port_param} $PORT $SSH_OPTIONS $SCP_SRC $USERNAME${USERNAME:+@}$SERVER $SCP_DST"
|
||||
}
|
||||
|
||||
# ssh
|
||||
run_ssh()
|
||||
{
|
||||
local cmd="$(prepare_ssh_cmd $1)"
|
||||
|
|
|
@ -3,7 +3,7 @@ set -e
|
|||
THIS_DIR_COMMON_SH=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
||||
export DOTFILES=$( cd "$THIS_DIR_COMMON_SH/.." && pwd )
|
||||
if [[ -f ~/.config/dotfiles/env ]]; then set -a; source ~/.config/dotfiles/env; set +a; fi
|
||||
if [[ "$DFS_DEBUG" == "1" ]]; then set -x; fi
|
||||
if [[ "$DFS_DEV" == "1" ]]; then set -x; fi
|
||||
DFS_CURL_OPTIONS="--retry 2 --max-time 20"
|
||||
|
||||
# parse args and set env, when it is sourced
|
||||
|
@ -17,8 +17,9 @@ if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
|
|||
case $ARG in
|
||||
-q*|--quite ) export DFS_QUIET=1 ;;
|
||||
-l*|--lite ) export DFS_LITE=1 ;;
|
||||
-d*|--dev ) export DFS_DEV=1; set -x ;;
|
||||
-D*|--dry-run ) export DFS_DRY_RUN=1 ;;
|
||||
--color ) export DFS_COLOR=1 ;;
|
||||
--dry-run ) export DFS_DRY_RUN=1 ;; # TODO!!!
|
||||
--*=* ) GOT_OPTS+=("${ARG%%=*}" "${ARG#*=}") ;;
|
||||
--* ) GOT_OPTS+=("$ARG") ;;
|
||||
-* ) GOT_OPTS+=("${ARG:0:2}") ;;
|
||||
|
|
Loading…
Reference in New Issue
Block a user