Debian Codegraph @

bin/cliapi

raw
1 #!/usr/bin/env perl
2
3 use utf8;
4 use strict;
5 use warnings;
6
7 use RDF::Trine qw(iri blank literal);
8 use RDF::Trine::Parser;
9 use RDF::Trine::Parser::LineProtocol;
10 use RDF::Trine::Error qw(:try);
11
12 if (scalar(@ARGV) and $ARGV[0] =~ /-h/) {
13 die usage();
14 }
15
16 my $cli = RDF::Trine::Parser::LineProtocol->new();
17 my $model = RDF::Trine::Model->new();
18
19 my $out = \*STDOUT;
20
21 print $out "# RDF::Trine-${RDF::Trine::VERSION}\n";
22 try {
23 while (defined(my $line = <>)) {
24 $cli->execute_line( $line, $model, $out );
25 }
26 } catch RDF::Trine::Error with {
27 my $e = shift;
28 warn $e->stacktrace;
29 };
30
31 ### pod & usage in one
32 sub usage {
33 my $usage .= << '=cut';
34 =pod
35
36 =head1 NAME
37
38 cliapi - a simple command line interface to an in-memory RDF quad store using the RDF Line Protocol
39
40 =head1 DESCRIPTION
41
42 cliapi is a simple program which maintains an in-memory RDF quad store and allows inserting,
43 deleting, and querying data using the RDF Line Protocol format.
44
45 =head1 SYNOPSIS
46
47 cliapi
48 ptar -h
49 ptar --help
50
51 =head1 OPTIONS
52
53 h Prints this help message
54
55 =head1 SEE ALSO
56
57 L<RDF::Trine::Parser::LineProtocol>.
58
59 =cut
60
61 ### strip the pod directives
62 $usage =~ s/=pod\n//g;
63 $usage =~ s/=head1 //g;
64
65 ### add some newlines
66 $usage .= $/.$/;
67
68 return $usage;
69 }
70