From 4447b1af1048fefe6c8cc0e1c066d726e32f1c54 Mon Sep 17 00:00:00 2001 From: Raphael Geissert Date: Wed, 11 Oct 2017 10:11:09 +0000 Subject: Add command completion git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@56604 e39458fd-73e7-0310-bf30-c45bca0a0e42 --- bin/check-new-issues | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'bin/check-new-issues') diff --git a/bin/check-new-issues b/bin/check-new-issues index 99699f70a8..314824cfeb 100755 --- a/bin/check-new-issues +++ b/bin/check-new-issues @@ -209,6 +209,27 @@ if ($term->ReadLine() eq 'Term::ReadLine::Stub') { 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 @@ TODO: foreach my $todo (reverse sort @todos) { 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"; -- cgit v1.2.3