Skip to content

Commit 8c2dd89

Browse files
committed
Handle the -a|--add argument coming first
Clean up log output target on error
1 parent c03e9fb commit 8c2dd89

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

git-ssh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ LC_ALL=C
2121
export LC_ALL
2222

2323
readonly APP_NAME="git-ssh"
24-
readonly VERSION="3.2.2"
24+
readonly VERSION="3.2.3"
2525
readonly CONFIG_VERSION=2
2626

2727
# Where our configs live
@@ -69,7 +69,7 @@ reset Reset GIT_SSH_COMMAND, unsetting an exported configs
6969
help | -H | --help This help
7070
version | -V | --version Display application version
7171
EOF
72-
)"
72+
)" 1>&2
7373
return 0
7474
}
7575

@@ -97,7 +97,7 @@ _list_configs() {
9797
if { [ -n "${list_configs__verbose}" ] && { [ "${list_configs__verbose}" = "-v" ] || [ "${list_configs__verbose}" = "--verbose" ]; }; }; then
9898
_log 'Config: %s [%s]\n' "$(basename "${_config}")" "${_config}"
9999

100-
printf -- '%s\n\n' "$(cat "${_config}")"
100+
printf -- '%s\n\n' "$(cat "${_config}")" 1>&2
101101
else
102102
_config_namelen="$(printf -- '%s' "$(basename "${_config}")" | wc -m)"
103103
_config_spacelen="$((list_configs__spacecount - _config_namelen))"
@@ -128,7 +128,7 @@ Arguments:
128128
<path> The absolute file path to the SSH private key for this configuration.
129129
130130
EOF
131-
)"
131+
)" 1>&2
132132
}
133133

134134
##
@@ -304,7 +304,7 @@ Options:
304304
[-a | --add] Add the exported SSH key to the agent if it is not already present.
305305
306306
EOF
307-
)"
307+
)" 1>&2
308308
}
309309

310310
##
@@ -400,10 +400,17 @@ main() {
400400
return 0
401401
;;
402402
export)
403-
main__config="$2"
404-
if [ -z "${main__export_add_key}" ]; then
403+
# -a can be before the config or after the config like the old way
404+
case "$2" in
405+
-a | --add)
406+
main__export_add_key="$2"
407+
main__config="$3"
408+
;;
409+
*)
410+
main__config="$2"
405411
main__export_add_key="$3"
406-
fi
412+
;;
413+
esac
407414
_export_config "${main__config}" "${main__export_add_key}" || return 1
408415
return 0
409416
;;

0 commit comments

Comments
 (0)