-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmpresets
executable file
·93 lines (61 loc) · 1.67 KB
/
mpresets
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
#!/usr/bin/env perl
BEGIN {
if ((exists $ENV{MUTATE_HOME}) and (-d $ENV{MUTATE_HOME})) {
system "$ENV{MUTATE_HOME}/mbootstrap";
}
else {
die
"You must set MUTATE_HOME to the directory where Mutate is located.\n";
}
}
use 5.018_000;
use strict;
use warnings;
no if $] >= 5.018, warnings => "experimental::smartmatch";
no if $] >= 5.018, warnings => "experimental::lexical_subs";
use Getopt::Long qw/:config no_ignore_case /;
use Pod::Usage;
use File::Find;
use File::Basename;
my %obj;
GetOptions(
'help|?|h' => \$obj{options}->{'help'},
'event|e' => \$obj{options}->{'event'},
);
pod2usage "\nmpresets, Display Mutate Presets\n"
if defined $obj{options}->{help}
or not $ARGV[0];
unless (defined $obj{options}->{'event'}) {
find(\&process, "$ENV{MUTATE_HOME}/presets/");
sub process {
if (basename($File::Find::name) =~ /(\w+).(\w+)/) {
push @{$obj{presets}->{$1}}, $2;
}
}
for my $command (@ARGV) {
for (keys %{$obj{presets}}) {
if ($command eq $_) {
say $_;
say "\t$_" for @{$obj{presets}->{$_}};
}
}
}
}
else {
use Mojo::UserAgent;
my $ua = Mojo::UserAgent->new;
my $tx =
$ua->get("https://localhost:8443/mpresets" => {DNT => 1} => json =>
{arguments => "@ARGV"});
say $tx->res->body;
}
exit(0);
__END__
=head1 SYNOPSIS
<command> [options]
Options:
-h, -?, --help This help / usage screen...
-e, --event Submit this invocation to Mutate's Event Loop.
-o, --output Future: Format console output as JSON, YAML, XML
Example: mpresets mreader mwriter
=cut