withGetopt: sort getopt arguments
This commit is contained in:
parent
9f85824da2
commit
ab7e0c879c
@ -38,18 +38,31 @@ in writeDash wrapper-name ''
|
|||||||
|
|
||||||
wrapper_name=${shell.escape wrapper-name}
|
wrapper_name=${shell.escape wrapper-name}
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
for i in "$@"; do
|
||||||
|
case $i in
|
||||||
|
-h|--help)
|
||||||
|
${concatStringsSep "\n" (mapAttrsToList (name: opt: /* sh */ ''
|
||||||
|
printf ' %-16s %s\n' \
|
||||||
|
--${shell.escape opt.long} \
|
||||||
|
${shell.escape (opt.description or "undocumented flag")}
|
||||||
|
'') opts)}
|
||||||
|
exit
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
${concatStringsSep "\n" (mapAttrsToList (name: opt: /* sh */ ''
|
${concatStringsSep "\n" (mapAttrsToList (name: opt: /* sh */ ''
|
||||||
unset ${opt.varname}
|
unset ${opt.varname}
|
||||||
'') opts)}
|
'') opts)}
|
||||||
|
|
||||||
args=$(${utillinux}/bin/getopt \
|
args=$(${utillinux}/bin/getopt \
|
||||||
-n "$wrapper_name" \
|
|
||||||
-o "" \
|
|
||||||
-l ${shell.escape
|
-l ${shell.escape
|
||||||
(concatMapStringsSep ","
|
(concatMapStringsSep ","
|
||||||
(opt: opt.long + optionalString (!opt.switch) ":")
|
(opt: opt.long + optionalString (!opt.switch) ":")
|
||||||
(filter (opt: opt.long != null)
|
(filter (opt: opt.long != null)
|
||||||
(attrValues opts)))} \
|
(attrValues opts)))} \
|
||||||
|
-n "$wrapper_name" \
|
||||||
|
-o "" \
|
||||||
-s sh \
|
-s sh \
|
||||||
-- "$@")
|
-- "$@")
|
||||||
if \test $? != 0; then exit 1; fi
|
if \test $? != 0; then exit 1; fi
|
||||||
|
Loading…
Reference in New Issue
Block a user