-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (35 loc) · 843 Bytes
/
main.go
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
package main
import (
"fmt"
"os"
"github.com/jessevdk/go-flags"
)
var parser *flags.Parser
type scanCommand struct {
HostsCommand hostsCommand `command:"hosts" description:"Scan all available neighbor hosts of current local network"`
PortsCommand portsCommand `command:"ports" description:"Scan open ports on a host"`
}
func registerCommands(parser *flags.Parser) {
_, _ = parser.AddCommand(
"scan",
"Network scanner",
"Perform scanning over network",
&scanCommand{},
)
}
func init() {
parser = flags.NewParser(nil, flags.HelpFlag|flags.PassDoubleDash)
registerCommands(parser)
}
func main() {
if _, err := parser.Parse(); err != nil {
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrHelp {
os.Exit(0)
return
}
fmt.Printf("Error: %v\n", err)
os.Exit(1)
return
}
os.Exit(0)
}