~ubuntu-branches/ubuntu/vivid/mpv/vivid

« back to all changes in this revision

Viewing changes to TOOLS/zsh.pl

  • Committer: Package Import Robot
  • Author(s): Artur Rona
  • Date: 2015-02-08 11:38:05 UTC
  • mfrom: (28.1.4 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20150208113805-hb7kk68170y002es
Tags: 0.7.3-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - debian/rules:
    + Disable altivec on ppc64el again, as it FTBFS with it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
my $mpv = $ARGV[0] || 'mpv';
9
9
 
10
 
my @opts = parse_opts("$mpv --list-options", '^ (\-\-[^\s\*]*)\*?\s*(.*)', 1);
 
10
my @opts = parse_main_opts("$mpv --list-options", '^ (\-\-[^\s\*]*)\*?\s*(.*)');
11
11
 
12
12
my @ao = parse_opts("$mpv --ao=help", '^  ([^\s\:]*)\s*: (.*)');
13
13
my @vo = parse_opts("$mpv --vo=help", '^  ([^\s\:]*)\s*: (.*)');
54
54
          profiles=($profiles $current)
55
55
        fi
56
56
      done
57
 
      if [[ $state == profile ]]; then
 
57
      if [[ $state == show-profile ]]; then
58
58
        # For --show-profile, only one allowed
59
59
        if (( ${#profiles} > 0 )); then
60
60
          _values 'profile' $profiles && rc=0
118
118
    _describe -t values 'video filters' values && rc=0
119
119
  ;;
120
120
 
121
 
  profile|profiles)
 
121
  profile|show-profile)
122
122
$profile_comp
123
123
  ;;
124
124
 
133
133
    _tags files urls
134
134
    while _tags; do
135
135
      _requested files expl 'media file' _files -g \\
136
 
         "*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && rc=0
 
136
        "*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && rc=0
137
137
      if _requested urls; then
138
138
        while _next_label urls expl URL; do
139
139
          _urls "\$expl[@]" && rc=0
150
150
 
151
151
print $tmpl;
152
152
 
 
153
sub parse_main_opts {
 
154
    my ($cmd, $regex) = @_;
 
155
 
 
156
    my @list;
 
157
    my @lines = split /\n/, `$cmd`;
 
158
 
 
159
    foreach my $line (@lines) {
 
160
        my ($name, $desc) = ($line =~ /^$regex/) or next;
 
161
 
 
162
        next if ($desc eq 'removed' || $desc eq 'alias');
 
163
 
 
164
        if ($desc =~ /^Flag/) {
 
165
 
 
166
            push @list, $name;
 
167
 
 
168
            $name =~ /^--(.*)/;
 
169
            if ($1 !~ /^(\{|\}|v|list-options|really-quiet|no-.*)$/) {
 
170
                push @list, "--no-$1";
 
171
            }
 
172
 
 
173
        } elsif ($desc =~ /^Print/) {
 
174
 
 
175
            push @list, $name;
 
176
 
 
177
        } else {
 
178
 
 
179
            # Option takes argument
 
180
 
 
181
            my $entry = $name;
 
182
 
 
183
            $desc =~ s/\:/\\:/g;
 
184
            $entry .= "=-:$desc:";
 
185
 
 
186
            if ($desc =~ /^Choices\\: ([^(]*)/) {
 
187
                my $choices = $1;
 
188
                $choices =~ s/ +$//; # strip trailing space
 
189
                $entry .= "($choices)";
 
190
 
 
191
                # If "no" is one of the choices, it can also be
 
192
                # negated like a flag (--no-whatever).
 
193
                if ($choices =~ /\bno\b/) {
 
194
                    $name =~ s/^--/--no-/;
 
195
                    push @list, $name;
 
196
                }
 
197
            } elsif ($line =~ /\[file\]/) {
 
198
                $entry .= '->files';
 
199
            } elsif ($name =~ /^--(ao|vo|af|vf|profile|show-profile)$/) {
 
200
                $entry .= "->$1";
 
201
            }
 
202
            push @list, $entry;
 
203
        }
 
204
    }
 
205
 
 
206
    # Sort longest first, because zsh won't complete an option listed
 
207
    # after one that's a prefix of it.
 
208
    @list = sort {
 
209
        $a =~ /([^=]*)/; my $ma = $1;
 
210
        $b =~ /([^=]*)/; my $mb = $1;
 
211
 
 
212
        length($mb) <=> length($ma)
 
213
    } @list;
 
214
 
 
215
    return @list;
 
216
}
 
217
 
153
218
sub parse_opts {
154
 
    my ($cmd, $regex, $parsing_main_options) = @_;
 
219
    my ($cmd, $regex) = @_;
155
220
 
156
221
    my @list;
157
222
    my @lines = split /\n/, `$cmd`;
163
228
 
164
229
        my $entry = $1;
165
230
 
166
 
        if ($parsing_main_options) {
167
 
            $entry .= '=-';
168
 
        }
169
 
 
170
231
        if (defined $2) {
171
232
            my $desc = $2;
172
233
            $desc =~ s/\:/\\:/g;
173
 
 
174
234
            $entry .= ':' . $desc;
175
235
        }
176
236
 
177
 
        if ($parsing_main_options) {
178
 
            $entry .= ':';
179
 
 
180
 
            $entry .= '->ao' if ($1 eq '--ao');
181
 
            $entry .= '->vo' if ($1 eq '--vo');
182
 
            $entry .= '->af' if ($1 eq '--af');
183
 
            $entry .= '->vf' if ($1 eq '--vf');
184
 
            $entry .= '->profiles' if ($1 eq '--profile');
185
 
            $entry .= '->profile' if ($1 eq '--show-profile');
186
 
            $entry .= '->files' if ($line =~ /\[file\]/);
187
 
        }
188
 
 
189
237
        push @list, $entry
190
238
    }
191
239
 
192
 
    if ($parsing_main_options) {
193
 
        @list = sort {
194
 
            $a =~ /(.*?)\:/; my $ma = $1;
195
 
            $b =~ /(.*?)\:/; my $mb = $1;
196
 
 
197
 
            length($mb) <=> length($ma)
198
 
        } @list;
199
 
    }
200
 
 
201
240
    return @list;
202
241
}