summaryrefslogtreecommitdiff
path: root/helpers/check-feh-completion
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-03-19 21:35:53 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2010-03-19 21:35:53 +0100
commit35136dd4ac5b9ce6c71a0716e81e98e2aac7e77f (patch)
treecdef4cb77baa96dc93125fccfcadba3279d82ae0 /helpers/check-feh-completion
parentd6c9d090ff866c4c0ffd9a08779c2601b22d0a07 (diff)
Add helper to check if feh completion is up-to-date
Diffstat (limited to 'helpers/check-feh-completion')
-rwxr-xr-xhelpers/check-feh-completion38
1 files changed, 38 insertions, 0 deletions
diff --git a/helpers/check-feh-completion b/helpers/check-feh-completion
new file mode 100755
index 0000000..a6d0230
--- /dev/null
+++ b/helpers/check-feh-completion
@@ -0,0 +1,38 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use 5.010;
+
+my $man_path = "$ENV{HOME}/packages/feh/feh.1";
+my $comp_path = "$ENV{HOME}/packages/zsh/etc/completions/_feh";
+
+my @options;
+
+open(my $comp_file, '<', $comp_path) or die("Can't open $comp_path: $!");
+while (my $line = <$comp_file>) {
+
+ if ($line =~ /^ \t '(?<long> [\w-]+ )' \s+ '(?<short> . ) \+? ' $/xo) {
+ push(@options, [@+{'short', 'long'}]);
+ }
+ elsif ($line =~ /^ \t ' \*? -- (?<long> [\w-]+ ) \[/xo) {
+ push(@options, [undef, $+{'long'}]);
+ }
+
+}
+close($comp_file);
+
+open(my $man_file, '<', $man_path) or die("Can't open $man_path: $!");
+while (my $line = <$man_file>) {
+
+ if ($line !~ /^ \.B \s (?: -(?<short> . ), \s )? --(?<long> [\w-]+ )/xo) {
+ next;
+ }
+
+ if (not grep { $_ ~~ [@+{'short', 'long'}] } @options) {
+ printf("not in completion: %s %s\n",
+ $+{short} || ' ', $+{long},
+ );
+ }
+
+}
+close($man_file);