From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] config: get_1: use full parameter name
Date: Mon, 27 Sep 2021 02:53:07 -0500 [thread overview]
Message-ID: <20210927075307.13663-1-e@80x24.org> (raw)
Instead of passing the prefix section and key separately, pass
them together as is commonly done with git-config(1) usage as
well as our ->get_all API. This inconsistency in the get_1 API
is a needless footgun and confused me a bit while working on
"lei up" the other week.
---
lib/PublicInbox/Config.pm | 10 +++++-----
lib/PublicInbox/LEI.pm | 2 +-
lib/PublicInbox/LeiNoteEvent.pm | 2 +-
lib/PublicInbox/LeiUp.pm | 2 +-
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index b3bf5d12c416..d38f65863a49 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -385,10 +385,10 @@ sub rel2abs_collapsed {
}
sub get_1 {
- my ($self, $pfx, $k) = @_;
- my $v = $self->{"$pfx.$k"} // return;
+ my ($self, $key) = @_;
+ my $v = $self->{$key};
return $v if !ref($v);
- warn "W: $pfx.$k has multiple values, only using `$v->[-1]'\n";
+ warn "W: $key has multiple values, only using `$v->[-1]'\n";
$v->[-1];
}
@@ -430,7 +430,7 @@ sub _fill_ibx {
}
for my $k (qw(filter inboxdir newsgroup replyto httpbackendmax feedmax
indexlevel indexsequentialshard boost)) {
- my $v = get_1($self, $pfx, $k) // next;
+ my $v = get_1($self, "$pfx.$k") // next;
$ibx->{$k} = $v;
}
@@ -523,7 +523,7 @@ sub _fill_ei ($$) {
}
my $es = PublicInbox::ExtSearch->new($d);
for my $k (qw(indexlevel indexsequentialshard)) {
- my $v = get_1($self, $pfx, $k) // next;
+ my $v = get_1($self, "$pfx.$k") // next;
$es->{$k} = $v;
}
for my $k (qw(coderepo hide url infourl)) {
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 8faf74a29466..62150db150ab 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -1425,7 +1425,7 @@ sub refresh_watches {
require PublicInbox::LeiWatch;
$watches->{$url} //= PublicInbox::LeiWatch->new($url);
$seen{$url} = undef;
- my $state = $cfg->get_1("watch.$url", 'state');
+ my $state = $cfg->get_1("watch.$url.state");
if (!watch_state_ok($state)) {
$lei->err("watch.$url.state=$state not supported");
next;
diff --git a/lib/PublicInbox/LeiNoteEvent.pm b/lib/PublicInbox/LeiNoteEvent.pm
index 2a7b52c13487..1b714dae4393 100644
--- a/lib/PublicInbox/LeiNoteEvent.pm
+++ b/lib/PublicInbox/LeiNoteEvent.pm
@@ -73,7 +73,7 @@ sub lei_note_event {
$lei->{opt}->{quiet} = 1;
eval { $lms->arg2folder($lei, [ $folder ]) };
return if $@;
- my $state = $cfg->get_1("watch.$folder", 'state') // 'tag-rw';
+ my $state = $cfg->get_1("watch.$folder.state") // 'tag-rw';
return if $state eq 'pause';
return $lms->clear_src($folder, \$bn) if $new_cur eq '';
$lms->lms_pause;
diff --git a/lib/PublicInbox/LeiUp.pm b/lib/PublicInbox/LeiUp.pm
index 377a720eaf29..3e1ca21e29e7 100644
--- a/lib/PublicInbox/LeiUp.pm
+++ b/lib/PublicInbox/LeiUp.pm
@@ -32,7 +32,7 @@ sub up1 ($$) {
$lei->{opt}->{$k} //= $v;
}
for my $k ($lss->BOOL_FIELDS, $lss->SINGLE_FIELDS) {
- my $v = $lss->{-cfg}->get_1('lei.q', $k) // next;
+ my $v = $lss->{-cfg}->get_1("lei.q.$k") // next;
$lei->{opt}->{$k} //= $v;
}
my $o = $lei->{opt}->{output} // '';
reply other threads:[~2021-09-27 7:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210927075307.13663-1-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).