From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/2] lei sucks: sub-command to aid bug reporting
Date: Thu, 1 Apr 2021 02:32:38 -0700 [thread overview]
Message-ID: <20210401093238.23702-3-e@80x24.org> (raw)
In-Reply-To: <20210401093238.23702-1-e@80x24.org>
It's a bit of an Easter egg, though it's not possible to hide those
in Free Software... Anyways, it doesn't cost us an entry in %CMD
of LEI.pm and anybody frustrated enough with lei just might type
"lei sucks" on the command-line :>
---
MANIFEST | 1 +
lib/PublicInbox/LeiSucks.pm | 71 +++++++++++++++++++++++++++++++++++++
t/lei.t | 1 +
3 files changed, 73 insertions(+)
create mode 100644 lib/PublicInbox/LeiSucks.pm
diff --git a/MANIFEST b/MANIFEST
index 5e3b4aec..64293bb6 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -203,6 +203,7 @@ lib/PublicInbox/LeiQuery.pm
lib/PublicInbox/LeiRemote.pm
lib/PublicInbox/LeiSearch.pm
lib/PublicInbox/LeiStore.pm
+lib/PublicInbox/LeiSucks.pm
lib/PublicInbox/LeiTag.pm
lib/PublicInbox/LeiToMail.pm
lib/PublicInbox/LeiXSearch.pm
diff --git a/lib/PublicInbox/LeiSucks.pm b/lib/PublicInbox/LeiSucks.pm
new file mode 100644
index 00000000..d364a856
--- /dev/null
+++ b/lib/PublicInbox/LeiSucks.pm
@@ -0,0 +1,71 @@
+# Copyright (C) 2021 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+
+# Undocumented hidden command somebody might discover if they're
+# frustrated and need to report a bug. There's no manpage and
+# it won't show up in tab completions or help.
+package PublicInbox::LeiSucks;
+use strict;
+use v5.10.1;
+use Digest::SHA ();
+use Config;
+use POSIX ();
+use PublicInbox::Config;
+use PublicInbox::Search;
+
+sub lei_sucks {
+ my ($lei, @argv) = @_;
+ $lei->start_pager if -t $lei->{1};
+ my ($os, undef, $rel, undef, $mac)= POSIX::uname();
+ if ($mac eq 'x86_64' && $Config{ptrsize} == 4) {
+ $mac = $Config{cppsymbols} =~ /\b__ILP32__=1\b/ ? 'x32' : 'i386'
+ }
+ eval { require PublicInbox };
+ my $pi_ver = eval('$PublicInbox::VERSION') // '(???)';
+ my $daemon = $lei->{oneshot} ? 'oneshot' : 'daemon';
+ my @out = ("lei $pi_ver mode=$daemon\n",
+ "perl $Config{version} / $os $rel / $mac ".
+ "ptrsize=$Config{ptrsize}\n");
+ chomp(my $gv = `git --version` || "git missing");
+ $gv =~ s/ version / /;
+ my $json = ref(PublicInbox::Config->json);
+ $json .= ' ' . eval('$'.$json.'::VERSION') if $json;
+ $json ||= '(no JSON)';
+ push @out, "$gv / $json\n";
+ if (eval { require PublicInbox::Over }) {
+ push @out, 'SQLite '.
+ (eval('$DBD::SQLite::sqlite_version') // '(undef)') .
+ ', DBI '.(eval('$DBI::VERSION') // '(undef)') .
+ ', DBD::SQLite '.
+ (eval('$DBD::SQLite::VERSION') // '(undef)')."\n";
+ } else {
+ push @out, "Unable to load DBI / DBD::SQLite: $@\n";
+ }
+ if (PublicInbox::Search::load_xapian()) {
+ push @out, 'Xapian '.
+ join('.', map {
+ $PublicInbox::Search::Xap->can($_)->();
+ } qw(major_version minor_version revision)) .
+ ", bindings: $PublicInbox::Search::Xap";
+ my $xs_ver = eval '$'."$PublicInbox::Search::Xap".'::VERSION';
+ push @out, $xs_ver ? " $xs_ver\n" : " SWIG\n";
+ } else {
+ push @out, "Xapian not available: $@\n";
+ }
+ my $dig = Digest::SHA->new(1);
+ push @out, "public-inbox blob OIDs of loaded features:\n";
+ for my $m (grep(m{^PublicInbox/}, sort keys %INC)) {
+ my $f = $INC{$m};
+ $dig->add('blob '.(-s $f)."\0");
+ $dig->addfile($f);
+ push @out, ' '.$dig->hexdigest.' '.$m."\n";
+ }
+ push @out, <<'EOM';
+Let us know how it sucks! Please include the above and any other
+relevant information when sending plain-text mail to us at:
+meta@public-inbox.org -- archives: https://public-inbox.org/meta/
+EOM
+ $lei->out(@out);
+}
+
+1;
diff --git a/t/lei.t b/t/lei.t
index 0cf97866..2be9b4e8 100644
--- a/t/lei.t
+++ b/t/lei.t
@@ -154,6 +154,7 @@ my $test_fail = sub {
"error noted with q $fl");
}
}
+ lei_ok('sucks', \'yes, but hopefully less every day');
SKIP: {
skip 'no curl', 3 unless which('curl');
lei(qw(q --only http://127.0.0.1:99999/bogus/ t:m));
prev parent reply other threads:[~2021-04-01 9:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 9:32 [PATCH 0/2] lei sucks Eric Wong
2021-04-01 9:32 ` [PATCH 1/2] build: generate PublicInbox.pm with $VERSION Eric Wong
2021-04-01 9:32 ` Eric Wong [this message]
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=20210401093238.23702-3-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.
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).