-
Notifications
You must be signed in to change notification settings - Fork 22
/
swn_cli.pl
executable file
·53 lines (42 loc) · 1.22 KB
/
swn_cli.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
#!/usr/bin/env perl
use strict;
use warnings;
use File::Spec;
my ($cli_volume,$cli_directory,$cli_file) = File::Spec->splitpath(__FILE__);
use lib File::Spec->catpath($cli_volume,$cli_directory,'PerlLibs');
use lib File::Spec->catpath($cli_volume,$cli_directory,'extlib/lib/perl5');
use lib File::Spec->catpath($cli_volume,$cli_directory,'perl5/lib/perl5');
use DBI;
use FindBin;
use SWNPrompt;
use SWNUtil;
use SWN2PDF;
use SWN2WIKI;
my $time = time;
print STDOUT "STARS WITHOUT NUMBER\nSector Generator\n\n";
# Set up the DB handle
my $dbh = DBI->connect("dbi:SQLite:dbname=$FindBin::Bin/swn.sqlite",'','',
{ RaiseError => 1,
ReadOnly => 1 })
or die "Could not connect to DB: $!";
# Get the user input.
my ($command, $sector) = prompt_user( dbh => $dbh );
# Close the DBH before we do anything awkward with it.
$dbh->disconnect();
# Handle the 'exit' case
if (not defined $command or $command eq 'Q') {
print STDOUT "Exiting.\n";
exit;
}
# Handle the non-'exit' cases
if ($command eq 'PT' or $command eq 'PO') {
generate_pdf( sector => $sector,
time => $time,
);
}
if ($command eq 'PT' or $command eq 'TO') {
generate_wiki( sector => $sector,
time => $time,
);
}
exit;