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

New completion function (nmcli) and patch for _ffmpeg



Here's a new completion function for nmcli, the command line interface
to Linux' Network Manager. I've tried to make it as complete as
possible. It has been tested on version 0.8.5.92 that comes with
Fedora 14. I have also tried to make it compatible with nmcli 0.9.0
and 0.9.1 (the latest version) by observing the differences in the man
page. The man pages were almost unchanged, so it should work across
all versions.

Also, I've attached a patch for the FFmpeg completion function.
Nothing major has changed, but there are a couple of fixes that are
worth pushing upstream.

--
 Haakon
Index: _ffmpeg
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ffmpeg,v
retrieving revision 1.5
diff -u -1 -0 -r1.5 _ffmpeg
--- _ffmpeg	3 May 2011 18:38:56 -0000	1.5
+++ _ffmpeg	7 Nov 2011 17:27:29 -0000
@@ -14,20 +14,26 @@
     acodecs=(copy ${${(M)${(f)"$(_call_program audio-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]A[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
     _wanted ffmpeg-audio-codecs expl 'force audio codec (''copy'' to copy stream)' compadd -a acodecs
 }
 
 (( $+functions[_ffmpeg_vcodecs] )) || _ffmpeg_vcodecs() {
     local vcodecs
     vcodecs=(copy ${${(M)${(f)"$(_call_program video-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]V[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
     _wanted ffmpeg-video-codecs expl 'force video codec (''copy'' to copy stream)' compadd -a vcodecs
 }
 
+(( $+functions[_ffmpeg_scodecs] )) || _ffmpeg_scodecs() {
+    local scodecs
+    scodecs=(copy ${${(M)${(f)"$(_call_program video-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]S[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
+    _wanted ffmpeg-video-codecs expl 'force video codec (''copy'' to copy stream)' compadd -a scodecs
+}
+
 (( $+functions[_ffmpeg_formats] )) || _ffmpeg_formats() {
     local formats
     formats=(${(ou)${=${(s:,:)${${(M)${(f)"$(_call_program formats $words[1] -formats 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]][[:space:]][^[:space:]]##*}//(#b)????([^[:space:]]##)*/$match[1]}}}})
     _wanted ffmpeg-formats expl 'force format' compadd -a formats
 }
 
 (( $+functions[_ffmpeg_list_pix_fmts] )) || _ffmpeg_list_pix_fmts() {
     echo - ${${${(M)${(f)"$(_call_program formats $words[1] -pix_fmts 2>/dev/null)"}:#[I.][O.][H.][P.][B.] [^=[:space:]]*}#* }%% *}
 }
 
@@ -77,20 +83,21 @@
     fi
 
     return $ret
 }
 
 (( $+functions[_ffmpeg_register_lastopt_values] )) || _ffmpeg_register_lastopt_values() {
     if (( lastopt_takesargs )); then
         lastopt+=":$lastopt_description:"
         if (( $#lastopt_values )); then
             if [[ $lastopt_type == flags ]]; then
+                lastopt="*$lastopt"
                 flagtype=${${lastopt%%:*}#-}
                 lastopt+="->$flagtype"
                 _ffmpeg_flags[$flagtype]="${lastopt_values[*]}"
             else
                 lastopt+="(${lastopt_values[*]})"
             fi
         fi
     fi
     _ffmpeg_argspecs+=$lastopt
 }
@@ -118,32 +125,38 @@
             elif [[ $lastopt_description == [^[:space:]]##[[:space:]][[:space:]]* ]]; then
                 local example=${lastopt_description%% *}
                 example=${example//:/\\:}
                 lastopt_description=${lastopt_description##[^[:space:]]##[[:space:]]##}
                 lastopt_description=${lastopt_description//:/\\:}
                 if [[ $example == filename ]]; then
                     lastopt_takesargs=0
                     lastopt+=":$lastopt_description:_files"
                 elif [[ $lastopt == -[asv]pre ]]; then
                     lastopt_takesargs=0
+                    lastopt="*$lastopt"
                     lastopt+=": :_ffmpeg_presets"
                 elif [[ $lastopt == -acodec ]]; then
                     lastopt_takesargs=0
                     lastopt+=": :_ffmpeg_acodecs"
                 elif [[ $lastopt == -vcodec ]]; then
                     lastopt_takesargs=0
                     lastopt+=": :_ffmpeg_vcodecs"
+                elif [[ $lastopt == -scodec ]]; then
+                    lastopt_takesargs=0
+                    lastopt+=": :_ffmpeg_scodecs"
                 elif [[ $lastopt == -f ]]; then
                     lastopt_takesargs=0
+                    lastopt="*$lastopt"
                     lastopt+=": :_ffmpeg_formats"
                 elif [[ $lastopt == -pix_fmt ]]; then
                     lastopt_takesargs=0
+                    lastopt="*$lastopt"
                     lastopt+=": :_ffmpeg_pix_fmts"
                 elif [[ $example == bitstream_filter ]]; then
                     lastopt_takesargs=0
                     lastopt+=": :_ffmpeg_bsfs"
                 else
                     lastopt_takesargs=1
                     lastopt_description+=" ($example)"
                 fi
             else
                 lastopt_takesargs=0

Attachment: _nmcli
Description: Binary data



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