-
Notifications
You must be signed in to change notification settings - Fork 38
/
shellArgs.go
30 lines (22 loc) · 754 Bytes
/
shellArgs.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
/* Processing and handling Shell Arguments */
package main
import (
"flag"
"log"
)
// Processing Shell Arguments
func processShellArgs() (int, string) {
// Reading Shell Args
port := flag.Int("port", DefaultHTTPPort,
"Define the port on which the webserver will listen to")
filePath := flag.String("file", DefaultComputerFilePath,
"Path to the CSV file containing the list of hosts ")
flag.Parse()
flagset := make(map[string]bool)
flag.Visit(func(f *flag.Flag) { flagset[f.Name]=true } )
// Try to Stat the File if not Fail Fatal
if flagset["file"] && !FileExists(*filePath) {
log.Fatalf("Could not find or access Computerlist --file Argument Value: \"%s\"", *filePath)
}
return *port, *filePath
}