-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdropbox-ignore.go
42 lines (37 loc) · 1.03 KB
/
dropbox-ignore.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
package main
import (
"flag"
"fmt"
log "github.com/sirupsen/logrus"
dropbox "github.com/willfantom/dropbox-ignore/dropbox"
"github.com/willfantom/dropbox-ignore/files"
)
const (
defaultFile string = "./.dbignore"
defaultRoot string = "."
gitignoreFile string = "./.gitignore"
)
func main() {
fmt.Println("Dropbox Ignore...")
useGitIgnore := flag.Bool("g", false, "use .gitignore file rather then .dbignore")
debugLevel := flag.Bool("d", false, "get debug level logs")
doUpdate := flag.Bool("u", false, "also mark files to sync that don't match")
flag.Parse()
if *debugLevel {
log.SetLevel(log.DebugLevel)
}
ignoreFile := defaultFile
if *useGitIgnore {
ignoreFile = gitignoreFile
}
files, err := files.GetIgnoredList(ignoreFile, defaultRoot)
if err != nil {
log.Fatalf("could not parse directory for dropbox ignore")
}
count := dropbox.IgnoreFiles(files)
fmt.Printf("...Ignored %d files \n", count)
if *doUpdate {
updateCount := dropbox.SyncFiles(files)
fmt.Printf("...Un-Ignored %d files \n", updateCount)
}
}