-
Notifications
You must be signed in to change notification settings - Fork 0
/
mian.go
50 lines (38 loc) · 814 Bytes
/
mian.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
45
46
47
48
49
50
package main
import (
"fmt"
"log"
"os"
"ti/main/ipAddress"
)
func fileOption(argsWithoutProg []string, index int) []*ipAddress.IPAddress {
stringArray, err := readFile(argsWithoutProg[index + 1])
if err != nil {
fmt.Println(err)
}
return ipAddress.AddressesMapper(stringArray)
}
func createOutputFile(name string) *os.File {
f, err := os.Create(name)
if err != nil {
log.Fatal(err)
}
return f
}
func main() {
argsWithoutProg := os.Args[1:]
for i, s := range argsWithoutProg {
switch {
case s == "--file" || s =="-f":
mainAddressesArray := fileOption(argsWithoutProg, i)
for _, address := range mainAddressesArray {
address.ExtendAndReduceSubnets()
}
err := saveAddressesInFile(mainAddressesArray)
if err != nil {
println(err.Error())
}
break
}
}
}