-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun.pl
executable file
·126 lines (81 loc) · 2.97 KB
/
run.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/perl
use v5.10;
use strict;
use warnings;
use Carp;
use File::Spec;
use FindBin;
use Getopt::Long qw(:config no_ignore_case);
use Pod::Usage;
use lib $FindBin::Bin;
use _version qw($VERSION);
use indexer qw(:all);
use sourcetraildb;
sub sourcetrail_fatal {
say 'ERROR: ' . sourcetraildb::getLastError();
exit(2);
}
my ( $clear, $database_file_path, $source_file_path, $verbose );
GetOptions(
'clear!' => \$clear,
'database-file-path=s' => \$database_file_path,
'help|?' => sub { pod2usage( -verbose => 1 ) },
'man' => sub { pod2usage( -verbose => 2 ) },
'source-file-path=s' => \$source_file_path,
'verbose|v!' => \$verbose,
'version|V' => sub { say "$0 version $VERSION"; exit },
);
pod2usage() unless $database_file_path && $source_file_path;
exit(2) unless is_sourcetraildb_version_compatible();
$database_file_path = File::Spec->rel2abs($database_file_path);
$source_file_path = File::Spec->rel2abs($source_file_path);
sourcetrail_fatal() unless sourcetraildb::open($database_file_path);
if ($clear) {
say 'INFO: Clearing database...' if $verbose;
sourcetrail_fatal() unless sourcetraildb::clear();
say 'INFO: Clearing done.' if $verbose;
}
sourcetraildb::beginTransaction();
index_source_file( $source_file_path, $verbose );
sourcetraildb::commitTransaction();
sourcetrail_fatal() unless sourcetraildb::close();
__END__
=head1 NAME
run.pl - Perl source code indexer that generates a Sourcetrail compatible database
=head1 SYNOPSIS
run.pl [--help] [--man] [--version] --database-file-path=DATABASE_FILE_PATH
--source-file-path=SOURCE_FILE_PATH [--clear] [--verbose]
Options:
--help print brief help message and exit
--man show full documentation and exit
--version print version of this program and exit
--database-file-path path to the generated Sourcetrail database file (required)
--source-file-path path to the generated Sourcetrail database file (required)
--clear clear the database before indexing
--verbose enable verbose console output
=head1 DESCRIPTION
Index a Perl source file and store the indexed data to a Sourcetrail database file.
=head1 OPTIONS
=over
=item B<-c>, B<--clear>
clear the database before indexing
=item B<-d> I<path>, B<--database-file-path>=I<path>
path to the generated Sourcetrail database file (required)
=item B<-m>, B<--man>
show full documentation and exit
=item B<-h>, B<--help>
print brief help message and exit
=item B<-s> I<path>, B<--source-file-path>=I<path>
path to the source file to index (required)
=item B<-v>, B<--verbose>
enable verbose console output
=item B<-V>, B<--version>
print version of this program and exit
=back
=head1 AUTHOR
Andrew Pam L<mailto:[email protected]>
=head1 COPYRIGHT AND LICENSE
Copyright 2019 Andrew Pam
This program is licensed under the GNU General Public License v3.0 or later
SPDX-License-Identifier: GPL-3.0-or-later
=cut