Author: geissert
Date: 2017-10-11 10:11:09 +0000 (Wed, 11 Oct 2017)
New Revision: 56604

Modified:
   bin/check-new-issues
Log:
Add command completion


Modified: bin/check-new-issues
===================================================================
--- bin/check-new-issues        2017-10-11 09:30:47 UTC (rev 56603)
+++ bin/check-new-issues        2017-10-11 10:11:09 UTC (rev 56604)
@@ -209,6 +209,27 @@
        print "Install libterm-readline-gnu-perl to get readline support!\n";
 }
 
+my $attribs = $term->Attribs;
+
+$attribs->{completion_word} = [ qw(.f .c .w .m .r ! v e - .help q) ];
+
+sub initial_completion {
+    my ($text, $line, $start, $end) = @_;
+
+    $attribs->{attempted_completion_over} = 1;
+
+
+    # If first word then complete commands
+    if (substr($line, 0, $start) =~ /^\s*[.]?$/) {
+       return $term->completion_matches($text,
+                                        $attribs->{list_completion_function});
+    } else {
+       return;
+    }
+}
+
+$attribs->{attempted_completion_function} = \&initial_completion;
+
 TODO: foreach my $todo (reverse sort @todos) {
        print ${$data->{$todo}->{CVE}} if $data->{$todo}->{CVE};
        print ${$data->{$todo}->{entry}};
@@ -272,10 +293,10 @@
                        print "exit status: $?\n";
                        next READ;
                }
-               elsif ($r=~ /^q$/i ) {
+               elsif ($r=~ /^q\s?$/i ) {
                        last TODO;
                }
-               elsif ($r=~ /^[ve]$/i ) {
+               elsif ($r=~ /^[ve]\s?$/i ) {
                        my $newentry=edit_entry(${$data->{$todo}->{entry}});
                        if ( $newentry eq ${$data->{$todo}->{entry}} ) {
                                print "Not changed.\n";


_______________________________________________
Secure-testing-commits mailing list
Secure-testing-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/secure-testing-commits

Reply via email to