From a5d60c9edfe3c61374ed24c08f2cd716188f55a1 Mon Sep 17 00:00:00 2001 From: Bjoern Petri Date: Wed, 8 Apr 2020 19:44:07 +0200 Subject: [PATCH] Add --remote argument (#28) Co-authored-by: Bjoern Petri --- Readme.md | 1 + bin/shipit | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 8e549ac..29e622e 100644 --- a/Readme.md +++ b/Readme.md @@ -39,6 +39,7 @@ shipit [option] | Option | Description | | --------------- | ----------- | | -c, --config | Config file path (default: `.shipit`) | +| -r, --remote | Override remote host | | -v, --verbose | Enable verbose mode for SSH | ### Examples diff --git a/bin/shipit b/bin/shipit index cda767d..f703aad 100755 --- a/bin/shipit +++ b/bin/shipit @@ -51,6 +51,7 @@ usage() { echo "Options:" echo echo " -c, --config Config file name (default: .shipit)" + echo " -r, --remote Override remote host" echo " -v, --verbose Enable verbose mode for SSH" echo } @@ -79,6 +80,12 @@ set_config_file() { CONFIG_NAME="$1" } +# Set remote host +set_remote_host() { + test -z "$1" && abort 'Hostname is required for --remote/-r option.' + SSH_HOST="$1" +} + # Print squirrel squirrel() { echo "$WHITE" @@ -122,7 +129,7 @@ read_config() { test -z "$host" || test -z "$path" && exit 1 # Expose params - SSH_HOST=$host + SSH_HOST="${SSH_HOST:-$host}" SSH_PATH=$path } @@ -245,6 +252,7 @@ for arg in "$@"; do case "$arg" in -v|--verbose) set_verbose; shift ;; -c|--config) set_config_file "$2"; shift; shift ;; + -r|--remote) set_remote_host "$2"; shift; shift ;; esac done