+sub define_mode ($$) {
+ my ($optname,$f) = @_;
+ push @options, $optname, sub {
+ die "only one mode may be specified\n" if defined $mode;
+ $mode=$f;
+ };
+}
+
+define_mode('bdf-filter', sub {
+ die if @ARGV;
+
+ processbdf((new IO::File '<&STDIN'),
+ (new IO::File '>&STDOUT'));
+});
+
+Getopt::Long::Configure(qw(bundling));
+GetOptions(@options) or exit 127;
+
+push @rulespath, "$sharedir/rules" unless @rulespath;
+
+die "need a mode\n" unless $mode;
+
+$mode->();