summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--krebs/5pkgs/simple/withGetopt.nix17
1 files changed, 15 insertions, 2 deletions
diff --git a/krebs/5pkgs/simple/withGetopt.nix b/krebs/5pkgs/simple/withGetopt.nix
index b7bd40126..7a19ccd29 100644
--- a/krebs/5pkgs/simple/withGetopt.nix
+++ b/krebs/5pkgs/simple/withGetopt.nix
@@ -38,18 +38,31 @@ in writeDash 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 */ ''
unset ${opt.varname}
'') opts)}
args=$(${utillinux}/bin/getopt \
- -n "$wrapper_name" \
- -o "" \
-l ${shell.escape
(concatMapStringsSep ","
(opt: opt.long + optionalString (!opt.switch) ":")
(filter (opt: opt.long != null)
(attrValues opts)))} \
+ -n "$wrapper_name" \
+ -o "" \
-s sh \
-- "$@")
if \test $? != 0; then exit 1; fi