refact code to remove Switch lib (deprecated)

master
GouveaHeitor 2020-05-27 09:59:12 -03:00
parent 0099e37181
commit 854d9ec0a4
2 changed files with 30 additions and 21 deletions

View File

@ -7,7 +7,7 @@
<img src="https://img.shields.io/badge/license-MIT-blue.svg">
</a>
<a href="https://github.com/GouveaHeitor/nipe/releases">
<img src="https://img.shields.io/badge/version-0.9.2-blue.svg">
<img src="https://img.shields.io/badge/version-0.9.3-blue.svg">
</a>
</p>
</p>
@ -34,7 +34,7 @@ All non-local UDP/ICMP traffic is also blocked by the Tor project.
$ git clone https://github.com/GouveaHeitor/nipe && cd nipe
# Install libs and dependencies
$ sudo cpan install Switch JSON Config::Simple
$ sudo cpan install Config::Simple JSON
$ perl nipe.pl install
```
---

47
nipe.pl
View File

@ -1,7 +1,9 @@
#!/usr/bin/env perl
use 5.018;
use Switch;
use strict;
use warnings;
use Try::Tiny;
use lib "./lib/";
use Nipe::Engine::Stop;
use Nipe::Engine::Start;
@ -11,27 +13,34 @@ use Nipe::Utils::Helper;
use Nipe::Utils::Install;
sub main {
my $command = $ARGV[0];
my $argument = $ARGV[0];
switch ($command) {
case "stop" {
Nipe::Engine::Stop -> new();
}
case "start" {
Nipe::Engine::Start -> new();
}
case "status" {
print Nipe::Utils::Status -> new();
}
case "restart" {
Nipe::Engine::Restart -> new();
}
case "install" {
Nipe::Utils::Install -> new();
}
if ($argument) {
my $commands = {
stop => "Nipe::Engine::Stop",
start => "Nipe::Engine::Start",
status => "Nipe::Utils::Status",
restart => "Nipe::Engine::Restart",
install => "Nipe::Utils::Install",
help => "Nipe::Utils::Helper"
};
print Nipe::Utils::Helper -> new();
try {
my $exec = $commands -> {$argument} -> new();
if ($exec ne "1") {
print $exec;
}
}
catch {
print "\n[!] ERROR: this command could not be run\n\n";
};
return 1;
}
return print Nipe::Utils::Helper -> new();
}
main();