[Pkg-ocaml-maint-commits] [SCM] polygen packaging branch, master, updated. debian/1.0.6.ds2-10-4-gf37594a
Enrico Zini
enrico at enricozini.org
Wed Mar 9 23:10:38 UTC 2011
The following commit has been merged in the master branch:
commit f37594a9ee7ad147f8348f9e719dffe0f28d8469
Author: Enrico Zini <enrico at enricozini.org>
Date: Wed Mar 9 23:09:29 2011 +0000
Implemented polyrun --complete
diff --git a/debian/polyrun b/debian/polyrun
index ab2dbc4..02b7371 100755
--- a/debian/polyrun
+++ b/debian/polyrun
@@ -57,6 +57,50 @@ sub grmfind ($)
return undef;
}
+# Compute grammar tab completions
+sub grmcomplete ($)
+{
+ my $start = shift || "";
+ my %dirs;
+
+ # Scan all files, grouping them by grammar name
+ find({wanted => sub {
+ my $basename = $_;
+ $basename =~ s/.+\///;
+ push @{$dirs{$basename}}, $File::Find::name if (/\.grm$/);
+ },
+ no_chdir => 1,
+ }, '/usr/share/polygen');
+
+ # Build the unambiguous list
+ my @res;
+
+ for my $name (keys %dirs)
+ {
+ push @res, $name;
+ if (@{$dirs{$name}} > 1)
+ {
+ for my $pn (@{$dirs{$name}})
+ {
+ push @res, substr($pn, 19);
+ }
+ }
+ }
+
+ @res = sort @res;
+
+ for my $line (@res)
+ {
+ print $line, "\n" if (substr($line, 0, length($start)) eq $start);
+ }
+}
+
+if (@ARGV && $ARGV[0] eq '--complete')
+{
+ grmcomplete($ARGV[1]);
+ exit 0;
+}
+
my $scriptname = basename($0);
if ($scriptname eq 'polyfind')
--
polygen packaging
More information about the Pkg-ocaml-maint-commits
mailing list