commit f8e2d7ebaccbe7807927a1798f5f56063a6e3879 parent 63f4c1c3cf77be52918aef7e3de532a2deee248d Author: Natasha Kerensikova <natgh@instinctive.eu> Date: Tue, 15 Oct 2024 18:36:22 +0000 Argument parsing is homogeneized across `cmd_*` functions Diffstat:
M | src/pashage.sh | | | 33 | ++++++++++----------------------- |
1 file changed, 10 insertions(+), 23 deletions(-)
diff --git a/src/pashage.sh b/src/pashage.sh @@ -1142,9 +1142,6 @@ cmd_generate() { while [ $# -ge 1 ]; do case "$1" in - --) - shift - break ;; -c|--clip) if ! [ "${SHOW}" = text ]; then PARSE_ERROR=yes @@ -1184,6 +1181,9 @@ cmd_generate() { unset ARG unset REST ;; + --) + shift + break ;; -*) PARSE_ERROR=yes break ;; @@ -1337,30 +1337,17 @@ cmd_insert() { -m|--multiline) MULTILINE=yes shift ;; - --) - shift - break ;; - -e?*) - ECHO=yes - ARG="-${1#-e}" - shift - set -- "${ARG}" "$@" - unset ARG - ;; - -f?*) - OVERWRITE=yes - ARG="-${1#-f}" + -[efm]?*) + REST="${1#-?}" + ARG="${1%"${REST}"}" shift - set -- "${ARG}" "$@" + set -- "${ARG}" "-${REST}" "$@" unset ARG + unset REST ;; - -m?*) - MULTILINE=yes - ARG="-${1#-m}" + --) shift - set -- "${ARG}" "$@" - unset ARG - ;; + break ;; -?*) PARSE_ERROR=yes break ;;