From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1S2V1l-0000GA-0c for garchives@archives.gentoo.org; Tue, 28 Feb 2012 21:56:09 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0BE0CE076F; Tue, 28 Feb 2012 21:55:51 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id BBB6BE076C for ; Tue, 28 Feb 2012 21:55:51 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DF4531B400F for ; Tue, 28 Feb 2012 21:55:50 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id CC6D1E540F for ; Tue, 28 Feb 2012 21:55:47 +0000 (UTC) From: "Kent Fredric" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Kent Fredric" Message-ID: <1330465615.cb988b42b74fc9a5b4715df7122db7eb01d3e4ba.kent@gentoo> Subject: [gentoo-commits] proj/perl-overlay:master commit in: scripts/ X-VCS-Repository: proj/perl-overlay X-VCS-Files: scripts/package_log.pl X-VCS-Directories: scripts/ X-VCS-Committer: kent X-VCS-Committer-Name: Kent Fredric X-VCS-Revision: cb988b42b74fc9a5b4715df7122db7eb01d3e4ba X-VCS-Branch: master Date: Tue, 28 Feb 2012 21:55:47 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 17f95ac9-525d-4c03-bc85-d7b2ee2f34e1 X-Archives-Hash: d03cd34d27bd7b553e8f3028c0dbeda9 commit: cb988b42b74fc9a5b4715df7122db7eb01d3e4ba Author: Kent Fredric gmail com> AuthorDate: Tue Feb 28 21:46:55 2012 +0000 Commit: Kent Fredric gmail com> CommitDate: Tue Feb 28 21:46:55 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/perl-overlay.= git;a=3Dcommit;h=3Dcb988b42 [scripts/package_log.pl] update to use optparser , fix bug that was preve= nting specifiying multiple packages --- scripts/package_log.pl | 78 ++++++++++++++++++++++--------------------= ----- 1 files changed, 37 insertions(+), 41 deletions(-) diff --git a/scripts/package_log.pl b/scripts/package_log.pl index 22e571d..dc1a877 100755 --- a/scripts/package_log.pl +++ b/scripts/package_log.pl @@ -14,6 +14,7 @@ use env::gentoo::perl_experimental; use metacpan qw( mcpan ); use Term::ANSIColor qw( :constants ); use Try::Tiny; +use optparse; use coloriterator coloriser =3D> { -as =3D> 'author_colour' }, coloriser =3D> { -as =3D> 'dist_colour' }; @@ -34,20 +35,10 @@ use coloriterator # * CPAN::Changes # =20 -my $flags; -my $singleflags; - -@ARGV =3D grep { defined } map { - $_ =3D~ /^--(\w+)/ - ? do { $flags->{$1}++; undef } - : do { - $_ =3D~ /^-(\w+)/ - ? do { $singleflags->{$1}++; undef } - : do { $_ } - } -} @ARGV; - -if ( $flags->{help} or $singleflags->{h} ) { print help(); exit 0; } +my $optparse =3D optparse->new( + argv =3D> \@ARGV, + help =3D> sub { print help(); }, +); =20 my $oldest_date =3D '2011-10-01T00:00:00.000Z'; my $newest_date =3D '2012-02-01T00:00:00.000Z'; @@ -56,46 +47,51 @@ my $search =3D {}; =20 my $and =3D []; =20 -if ( not $flags->{all} ) { - push @{$and}, { - range =3D> { - date =3D> { - from =3D> $oldest_date, - #to =3D> $newest_date, - } - } - }; -} +if ( not $optparse->long_opts->{all} ) { + push @{$and}, { + range =3D> { + date =3D> { + from =3D> $oldest_date, =20 -push @{$and} , { - term =3D> { - 'distribution' =3D> @ARGV, -# minimum_match =3D> 1, + #to =3D> $newest_date, + } } -}; + }; +} + +#my $or =3D []; =20 -$search->{query} =3D { - constant_score =3D> { - filter =3D> { - and =3D> $and, - } - } +#for my $dist ( @{ $optparse->extra_opts } ) { + +push @{$and}, { + terms =3D> { + 'distribution' =3D> $optparse->extra_opts, + + # minimum_match =3D> 1, + } }; =20 +#} + +#push @{$and}, { +# or =3D> $or, +#}; + +$search->{query} =3D { constant_score =3D> { filter =3D> { and =3D> $and= , } } }; + $search->{sort} =3D [ =20 # { 'author' =3D> 'asc', }, { 'date' =3D> 'desc', }, ]; -$search->{size} =3D 10; +$search->{size} =3D 10000; =20 $search->{fields} =3D [qw( author name date distribution version )]; =20 -if ( $flags->{deps} ) { +if ( $optparse->long_opts->{deps} ) { push @{ $search->{fields} }, '_source.dependency'; } =20 - _log( ['initialized: fetching search results'] ); =20 my $results =3D mcpan->post( 'release/_search', $search ); @@ -106,7 +102,7 @@ for my $result ( @{ $results->{hits}->{hits} } ) { =20 # use Data::Dump qw(pp); # pp $result; - say $_ for format_result( $result->{fields}, $flags ); + say $_ for format_result( $result->{fields}, $optparse->long_opts ); } =20 exit 0; @@ -119,7 +115,7 @@ sub pp { require Data::Dump; goto \&Data::Dump::pp } sub gv { require Gentoo::PerlMod::Version; goto \&Gentoo::PerlMod::Versi= on::gentooize_version } =20 sub _log { - return unless $flags->{trace}; + return unless $optparse->long_opts->{trace}; return *STDERR->print(@_) if ( not ref $_[0] ); =20 state $prefix =3D "\e[7m* package_log.pl:\e[0m "; @@ -213,7 +209,7 @@ sub change_for { =20 return unless $file; =20 - if ( $flags->{'nosummarize'} ) { + if ( $optparse->long_opts->{'nosummarize'} ) { return $file; } =20