-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
35 lines (28 loc) · 963 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
package main
import (
"flag"
"fmt"
"time"
"github.com/gcodetec/nfcecompact/nfcecompact"
"github.com/spf13/viper"
)
func main() {
fmt.Println("listing files")
now := time.Now().Local()
currentYear := now.Year()
currentMonth := int(now.Month())
configFile := flag.String("f", "config", "seta o arquivo de configuração")
competenceYear := flag.Int("year", currentYear, "o diretorio dos arquivos")
competenceMonth := flag.Int("month", currentMonth, "o diretorio dos arquivos")
flag.Parse()
viper.SetConfigName(*configFile)
viper.AddConfigPath(".")
err := viper.ReadInConfig() // Find and read the config file
if err != nil { // Handle errors reading the config file
panic(fmt.Errorf("fatal error config file: %s", err))
}
path := viper.GetString("path")
copyPath := viper.GetString("copy_path")
nfcecompact.CopyAllFilesToPath(copyPath, path)
nfcecompact.CompactFilesByCompetence(path, *competenceYear, *competenceMonth)
}