* [PATCH 06/10] lei completion: handle URLs with port numbers
2021-01-23 10:27 5% [PATCH 00/10] lei: externals more stuff Eric Wong
@ 2021-01-23 10:27 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-01-23 10:27 UTC (permalink / raw)
To: meta
This improves the experience for developers running local
instances of PublicInbox::WWW without permissions to bind
port 80 or 443.
---
lib/PublicInbox/LeiExternal.pm | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/lib/PublicInbox/LeiExternal.pm b/lib/PublicInbox/LeiExternal.pm
index 59c3c367..a4e644ee 100644
--- a/lib/PublicInbox/LeiExternal.pm
+++ b/lib/PublicInbox/LeiExternal.pm
@@ -101,12 +101,36 @@ sub _complete_forget_external {
# Workaround bash word-splitting URLs to ['https', ':', '//' ...]
# Maybe there's a better way to go about this in
# contrib/completion/lei-completion.bash
- my $colon = ($argv[-1] // '') eq ':';
- my $re = $cur =~ /\A[\w-]/ ? '' : '.*';
+ my $re = '';
+ if (@argv) {
+ my @x = @argv;
+ if ($cur eq ':' && @x) {
+ push @x, $cur;
+ $cur = '';
+ }
+ while (@x > 2 && $x[0] !~ /\Ahttps?\z/ && $x[1] ne ':') {
+ shift @x;
+ }
+ if (@x >= 2) { # qw(https : hostname : 443) or qw(http :)
+ $re = join('', @x);
+ } else { # just filter out the flags and hope for the best
+ $re = join('', grep(!/^-/, @argv));
+ }
+ $re = quotemeta($re);
+ }
+ # FIXME: bash completion off "http:" or "https:" when the last
+ # character is a colon doesn't work properly even if we're
+ # returning "//$HTTP_HOST/$PATH_INFO/", not sure why, could
+ # be a bash issue.
map {
my $x = substr($_, length('external.'));
# only return the part specified on the CLI
- $colon && $x =~ /(\Q$cur\E.*)/ ? $1 : $x;
+ if ($x =~ /\A$re(\Q$cur\E.*)/) {
+ # don't duplicate if already 100% completed
+ $cur eq $1 ? () : $1;
+ } else {
+ ();
+ }
} grep(/\Aexternal\.$re\Q$cur/, @{$cfg->{-section_order}});
}
^ permalink raw reply related [relevance 7%]
* [PATCH 00/10] lei: externals more stuff
@ 2021-01-23 10:27 5% Eric Wong
2021-01-23 10:27 7% ` [PATCH 06/10] lei completion: handle URLs with port numbers Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-01-23 10:27 UTC (permalink / raw)
To: meta
I don't know what I'm doing anymore, and maybe I never did.
Eric Wong (10):
lei: move external vivification to xsearch
lei: support remote externals
lei_to_mail: drop cyclic reference if not using IPC
lei: oneshot: preserve stdout if writing mbox
lei: default "-f $mfolder" args for common MUAs
lei completion: handle URLs with port numbers
lei forget-external: just show the location
lei q: support a bunch of curl(1) options
lei forget-external: do not show redundant "not found" lines
lei add-external: don't allow non-existent directories
lib/PublicInbox/LEI.pm | 46 +++++++----
lib/PublicInbox/LeiExternal.pm | 41 ++++++++--
lib/PublicInbox/LeiOverview.pm | 10 ++-
lib/PublicInbox/LeiQuery.pm | 68 ++++++++++++-----
lib/PublicInbox/LeiToMail.pm | 24 ++++--
lib/PublicInbox/LeiXSearch.pm | 136 ++++++++++++++++++++++++++++-----
lib/PublicInbox/ProcessPipe.pm | 2 +
script/lei | 2 +
t/lei.t | 43 +++++++++++
t/lei_xsearch.t | 5 +-
10 files changed, 309 insertions(+), 68 deletions(-)
^ permalink raw reply [relevance 5%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-01-23 10:27 5% [PATCH 00/10] lei: externals more stuff Eric Wong
2021-01-23 10:27 7% ` [PATCH 06/10] lei completion: handle URLs with port numbers Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).