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
Branches
No related tags found
No related merge requests found
......@@ -25,17 +25,26 @@ sub set
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
{
my $self= 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 @res;
foreach my $row (@$rows)
{
next unless ($row->{'title'} =~ m#$pattern#i);
next unless ($row->{$where} =~ m#$pattern#i);
# print "row: ", main::Dumper ($row);
push (@res, $row);
}
......
......@@ -88,9 +88,10 @@ print "op_code=[$op_code] par=[", join (';', @PAR), "]\n";
if ($op_code eq 'help') { usage(); }
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 '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')
{
my $f1= shift (@PAR);
......@@ -130,12 +131,14 @@ sub tom_toc
sub find_note
{
my $where= shift;
setup_toc();
my %uuid;
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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment