-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
44 lines (39 loc) · 1.03 KB
/
main.go
File metadata and controls
44 lines (39 loc) · 1.03 KB
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 (
"drive-janitor/parsing-conf"
"flag"
"fmt"
"os"
)
// checkConfigFileArgument checks if the config file argument is provided and valid
func checkConfigFileArgument(configPath *string) error {
flag.StringVar(configPath, "config", "", "Path to the config file")
flag.Parse()
if *configPath == "" {
fmt.Println("Error: config file path must be provided with -config flag")
flag.Usage()
return fmt.Errorf("config file path not provided")
} else if _, err := os.Stat(*configPath); os.IsNotExist(err) {
fmt.Printf("Error: config file %s does not exist\n", *configPath)
return fmt.Errorf("config file does not exist")
}
return nil
}
func main() {
var configPath string
if checkConfigFileArgument(&configPath) != nil {
os.Exit(1)
}
rules, err := parsing.ParsingConfigFile(configPath)
if err != nil {
fmt.Println("Error parsing config file: ", err)
os.Exit(1)
}
rules.Loop()
rules.WaitGroup.Wait()
close(rules.InfoLoop)
if err != nil {
fmt.Println("Error while looping on rules: ", err)
os.Exit(1)
}
}