Skip to content
Snippets Groups Projects
Commit 48599497 authored by Gerhard Gonter's avatar Gerhard Gonter :speech_balloon:
Browse files

added new command: show <uuid>

parent 605b042d
No related branches found
No related tags found
No related merge requests found
...@@ -25,17 +25,26 @@ sub set ...@@ -25,17 +25,26 @@ sub set
foreach my $par (keys %par) { $self->{$par}= $par{$par}; } foreach my $par (keys %par) { $self->{$par}= $par{$par}; }
} }
=head2 $toc->find($pattern [, $where])
Search TOC for matching $pattern in field specified by $where; if $where is not defined, 'title' is used.
Returns a list of matching TOC entries
=cut
sub find sub find
{ {
my $self= shift; my $self= shift;
my $pattern= shift; my $pattern= shift;
my $where= shift || 'title';
print "find: pattern=[$pattern]\n"; print "find: where=[$where] pattern=[$pattern]\n";
my ($mode, $toc, $rows)= $self->load_toc(); my ($mode, $toc, $rows)= $self->load_toc();
my @res; my @res;
foreach my $row (@$rows) foreach my $row (@$rows)
{ {
next unless ($row->{'title'} =~ m#$pattern#i); next unless ($row->{$where} =~ m#$pattern#i);
# print "row: ", main::Dumper ($row); # print "row: ", main::Dumper ($row);
push (@res, $row); push (@res, $row);
} }
......
...@@ -88,9 +88,10 @@ print "op_code=[$op_code] par=[", join (';', @PAR), "]\n"; ...@@ -88,9 +88,10 @@ print "op_code=[$op_code] par=[", join (';', @PAR), "]\n";
if ($op_code eq 'help') { usage(); } if ($op_code eq 'help') { usage(); }
elsif ($op_code eq 'dump') { dump_note ($_) foreach (@PAR); } elsif ($op_code eq 'dump') { dump_note ($_) foreach (@PAR); }
elsif ($op_code eq 'show') { find_note ('uuid', $_) foreach (@PAR); }
elsif ($op_code eq 'toc') { tom_toc(); } elsif ($op_code eq 'toc') { tom_toc(); }
elsif ($op_code eq 'csv') { tom_csv(); } elsif ($op_code eq 'csv') { tom_csv(); }
elsif ($op_code eq 'find') { find_note(@PAR); } elsif ($op_code eq 'find') { find_note('title', @PAR); }
elsif ($op_code eq 'diff') elsif ($op_code eq 'diff')
{ {
my $f1= shift (@PAR); my $f1= shift (@PAR);
...@@ -130,12 +131,14 @@ sub tom_toc ...@@ -130,12 +131,14 @@ sub tom_toc
sub find_note sub find_note
{ {
my $where= shift;
setup_toc(); setup_toc();
my %uuid; my %uuid;
foreach my $pattern (@_) foreach my $pattern (@_)
{ {
my @res= $toc->find ($pattern); my @res= $toc->find ($pattern, $where);
foreach my $res (@res) { $uuid{$res->{'uuid'}}= $res; } # TODO: count hits foreach my $res (@res) { $uuid{$res->{'uuid'}}= $res; } # TODO: count hits
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment