From d05334d9d8a7956eb6fcf706977cce1b2c06d858 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 10 Feb 2010 15:43:05 +0100 Subject: Add checkopts.pl --- dev/checkopts.pl | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 dev/checkopts.pl (limited to 'dev') diff --git a/dev/checkopts.pl b/dev/checkopts.pl new file mode 100755 index 0000000..b2cd6c1 --- /dev/null +++ b/dev/checkopts.pl @@ -0,0 +1,66 @@ +#!/usr/bin/env perl +## Copyright © 2010 by Daniel Friesel +## License: WTFPL +use strict; +use warnings; + +my $options; + +open(my $c_fh, '<', 'src/options.c') or die("Can't read options.c: $!"); +while (my $line = <$c_fh>) { + + if ($line =~ /\{"(?[\w-]+)",.*,\s*(?:'(?.)'|(?\d+))\}/o) { + push(@{$options->{$+{long}}}, ['source', $+{short}]); + } + elsif ($line =~ /" (?:\-(?.), |\s*)--(?[\w-]+) /) { + push(@{$options->{$+{long}}}, ['help', $+{short}]); + } + +} +close($c_fh); + +open(my $man_fh, '<', 'feh.1') or die("Can't read feh.1: $!"); +while (my $line = <$man_fh>) { + + if ($line =~ /^\.B (?:-(?.), )?--(?[\w-]+)/) { + push(@{$options->{$+{long}}}, ['manual', $+{short}]); + } + +} +close($man_fh); + +foreach my $option (keys %{$options}) { + my $last; + my $count = 0; + + if ($option =~ /^action\d/) { + next; + } + + foreach my $source (@{$options->{$option}}) { + my $name = $source->[0]; + my $short = $source->[1] // ''; + $short = '' if ($short =~ /^\d+$/); + + if (not defined $last) { + $last = $short; + } + + if ($last ne $short) { + last; + } + + $last = $short; + $count++; + } + + if ($count == 3) { + next; + } + + foreach my $source (@{$options->{$option}}) { + my $name = $source->[0]; + my $short = $source->[1] // ''; + print "$option: $name ($short)\n"; + } +} -- cgit v1.2.3