-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (32 loc) · 847 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
// This package provides CLI interface for the backup package in module root.
package main
import (
"bufio"
"log"
"os"
"github.com/alecthomas/kong"
backup "github.com/borsosl/go-local-backup"
)
// This is the CLI entry point of the backup application.
// See documentation at https://github.com/borsosl/go-local-backup/README.md
func main() {
var args struct {
Config string `arg:"" help:"Path to configuration"`
DryRun bool `short:"d" help:"Lists affected files without copying"`
}
kong.Parse(&args)
config, err := os.Open(args.Config)
if err != nil {
log.Fatal("Cannot read config file: ", err)
}
defer config.Close()
var cfg []string
scanner := bufio.NewScanner(config)
for scanner.Scan() {
cfg = append(cfg, scanner.Text())
}
err = backup.Backup(cfg, os.Stdout, args.DryRun)
if err != nil {
os.Exit(1)
}
}