refact code to remove Switch lib (deprecated)
parent
0099e37181
commit
854d9ec0a4
|
@ -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
|
||||
```
|
||||
---
|
||||
|
|
43
nipe.pl
43
nipe.pl
|
@ -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();
|
||||
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"
|
||||
};
|
||||
|
||||
try {
|
||||
my $exec = $commands -> {$argument} -> new();
|
||||
|
||||
if ($exec ne "1") {
|
||||
print $exec;
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
print Nipe::Utils::Helper -> new();
|
||||
catch {
|
||||
print "\n[!] ERROR: this command could not be run\n\n";
|
||||
};
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return print Nipe::Utils::Helper -> new();
|
||||
}
|
||||
|
||||
main();
|
||||
|
|
Loading…
Reference in New Issue