Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] Completion: Sort lz4 compression levels properly (+ a question)



This isn't super necessary but it irritated me.

Is there a better way to do this? Off the top of my head i came up with either
this state method or calling compadd from the argument spec... but both of those
involve an awful lot of boiler-plate just to keep some numbers sorted.

If there's no generic way to do it, would it make sense to have some kind of
spec modifier that tells action forms like `(item ...)` that -V should be used,
or, if that's too weird, a helper function (_presorted maybe) that just wraps
compadd?

dana


diff --git a/Completion/Unix/Command/_lz4 b/Completion/Unix/Command/_lz4
index d69091d00..4d2721bd5 100644
--- a/Completion/Unix/Command/_lz4
+++ b/Completion/Unix/Command/_lz4
@@ -42,8 +42,8 @@ args=(
   '(b t -k --keep)--rm[remove source file]'
   '!(b t -c --stdout)--to-stdout'
   + b # Benchmark-mode options
-  "(C c d t)-b-[benchmark file using specified compression level]::compression level:(${(j< >)levels//-/})"
-  "(C c d t)-e-[specify upper compression level limit (with -b)]:compression level:(${(j< >)levels//-/})"
+  '(C c d t)-b-[benchmark file using specified compression level]:: :->levels'
+  '(C c d t)-e-[specify upper compression level limit (with -b)]: :->levels'
   '(C c d t)-i-[specifiy minimum evaluation time (with -b)]:evaluation time (seconds)'
   + c # Compress-mode options
   "(b d t ${(j< >)levels} -c0 -c1 -c2 -hc)"${^levels}
@@ -98,6 +98,11 @@ case $state in
       _message 'no more arguments' && ret=0
     fi
     ;;
+  levels)
+    _wanted -2V levels expl 'compression level' \
+      compadd - ${(@on)levels//-/} \
+    && ret=0
+    ;;
 esac
 
 return ret



Messages sorted by: Reverse Date, Date, Thread, Author