-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsentra.pl
59 lines (47 loc) · 1.5 KB
/
sentra.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
#!/usr/bin/env perl
use 5.030;
use strict;
use warnings;
use lib './lib/';
use Getopt::Long qw(:config no_ignore_case);
use Sentra::Utils::Helper;
use Sentra::Engine::Maintained;
use Sentra::Engine::SearchFiles;
use Sentra::Engine::SlackWebhook;
use Sentra::Engine::DependabotMetrics;
sub main {
my ($org, $token, $webhook, $message, $help, %options);
my $per_page = 100;
GetOptions (
'o|org=s' => \$org,
't|token=s' => \$token,
'w|webhook=s' => \$webhook,
'm|message=s' => \$message,
'h|help' => \$help,
'mt|maintained' => \$options{'maintained'},
'd|dependency' => \$options{'dependency'},
'M|metrics' => \$options{'metrics'},
);
my %dispatch_table = (
'metrics' => sub { Sentra::Engine::DependabotMetrics -> new($org, $token, $per_page) },
'dependency' => sub { Sentra::Engine::SearchFiles -> new($org, $token, $per_page) },
'maintained' => sub { Sentra::Engine::Maintained -> new($org, $token, $per_page) },
);
for my $option (keys %options) {
if ($options{$option} && exists $dispatch_table{$option}) {
print $dispatch_table{$option}->();
}
}
if ($webhook && $message) {
my $send = Sentra::Engine::SlackWebhook -> new($message, $webhook);
if ($send) {
return 0;
}
}
if ($help) {
print Sentra::Utils::Helper -> new();
return 0;
}
return 1;
}
exit main();