From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C35E41F9E5 for ; Sun, 30 May 2021 06:33:58 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/4] lei lcat+inspect: start wiring up completion Date: Sun, 30 May 2021 06:33:55 +0000 Message-Id: <20210530063358.25095-2-e@80x24.org> In-Reply-To: <20210530063358.25095-1-e@80x24.org> References: <20210530063358.25095-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Colons and other delimiters still cause problems for our bash completion, but some completion is better than no completion. --- lib/PublicInbox/LeiInspect.pm | 8 ++++++++ lib/PublicInbox/LeiLcat.pm | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/PublicInbox/LeiInspect.pm b/lib/PublicInbox/LeiInspect.pm index 7205979e..eb2634b4 100644 --- a/lib/PublicInbox/LeiInspect.pm +++ b/lib/PublicInbox/LeiInspect.pm @@ -99,4 +99,12 @@ sub lei_inspect { $lei->out(']') if $multi; } +sub _complete_inspect { + my ($lei, @argv) = @_; + my $sto = $lei->_lei_store or return; + my $lms = $sto->search->lms or return; + my $match_cb = $lei->complete_url_prepare(\@argv); + map { $match_cb->($_) } $lms->folders; +} + 1; diff --git a/lib/PublicInbox/LeiLcat.pm b/lib/PublicInbox/LeiLcat.pm index effc3682..81ab1e36 100644 --- a/lib/PublicInbox/LeiLcat.pm +++ b/lib/PublicInbox/LeiLcat.pm @@ -132,4 +132,12 @@ no args allowed on command-line with --stdin $lei->_start_query; } +sub _complete_lcat { + my ($lei, @argv) = @_; + my $sto = $lei->_lei_store or return; + my $lms = $sto->search->lms or return; + my $match_cb = $lei->complete_url_prepare(\@argv); + grep(m!\A[a-z]+://!, map { $match_cb->($_) } $lms->folders); +} + 1;