[Rt-commit] rt branch, 4.4/rt-search-attributes, repushed

Dustin Graves dustin at bestpractical.com
Fri Oct 23 11:17:41 EDT 2015


The branch 4.4/rt-search-attributes was deleted and repushed:
       was 589ee4832e1bde5421344694c8d057b54614e44f
       now c40197339d19a5800ba5e3b02caac64cafb9caa3

1:  589ee48 ! 1:  c401973 add script to search attributes
    @@ -83,7 +83,7 @@
     +
     +my ($name, $search) = @ARGV;
     +
    -+if ($args{help} || !$name) {
    ++if ($args{help} || @ARGV < 2) {
     +    require Pod::Usage;
     +    Pod::Usage::pod2usage({ verbose => 2 });
     +    exit;
    @@ -108,33 +108,29 @@
     +
     +use Data::Dumper;
     +
    -+# compile search code into sub since eval is slow
    -+my $predicate;
    -+$predicate = eval "
    ++my $predicate = eval '
     +    sub {
    -+        my \$attr = shift;
    -+        my (      \$Id,       \$ObjectType,       \$ObjectId,       \$Name,       \$Description,       \$Content) =
    -+           (\$attr->Id, \$attr->ObjectType, \$attr->ObjectId, \$attr->Name, \$attr->Description, \$attr->Content);
    ++        my $attr = shift;
    ++        my (      $Id,       $ObjectType,       $ObjectId,       $Name,       $Description,       $Content) =
    ++           ($attr->Id, $attr->ObjectType, $attr->ObjectId, $attr->Name, $attr->Description, $attr->Content);
     +
     +        # allow lowercase to be kind
    -+        my (\$id, \$objecttype, \$objectid, \$name, \$description, \$content) =
    -+           (\$Id, \$ObjectType, \$ObjectId, \$Name, \$Description, \$Content);
    ++        my ($id, $objecttype, $objectid, $name, $description, $content) =
    ++           ($Id, $ObjectType, $ObjectId, $Name, $Description, $Content);
     +
     +        # shorthand for content
    -+        \$_ = \$attr->Content;
    ++        local $_ = $attr->Content;
     +
     +        # return executed search code
    -+        $search;
    -+    }" if defined $search;
    ++        ' .
    ++        $search .';'.
    ++   '}';
     +
    -+if (defined $search and not defined $predicate) {
    -+    print "Error evaluating expression '$search'\n";
    -+    exit;
    -+}
    ++die $@ if ($@);
     +
     +while ( my $attr = $attrs->Next ) {
     +    # search for desired field
    -+    if (not defined $predicate or $predicate->($attr)) {
    ++    if ($predicate->($attr)) {
     +        # print attribute's information
     +        foreach my $field ( @fields ) {
     +            print "$field: " . $attr->$field . "\n";
    @@ -154,13 +150,12 @@
     +
     +=head1 SYNOPSIS
     +
    -+rt-search-attributes [OPTION] ATTRIBUTE_NAME [QUALIFYING_CODE]
    ++rt-search-attributes [OPTION] ATTRIBUTE_NAME QUALIFYING_CODE
     +
     +=head1 DESCRIPTION
     +
    -+This script searches all attributes named ATTRIBUTE_NAME with optional
    -+qualifying code QUALIFYING_CODE and prints out the details of matching
    -+attributes.
    ++This script searches all attributes named ATTRIBUTE_NAME with qualifying
    ++code QUALIFYING_CODE and prints out the details of matching attributes.
     +
     +QUALIFYING_CODE can use a number of variables to call on RT::Attribute's
     +properties:
    @@ -176,5 +171,4 @@
     +e.g.
     +
     +rt-search-attributes SavedSearch '$id > 10'
    -+rt-search-attributes HomepageSettings
     +rt-search-attributes Search '$_->{Query} =~ /Status/'



More information about the rt-commit mailing list