-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
85 lines (72 loc) · 1.75 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package main
import (
"flag"
"log"
"strings"
)
var MOVE_RESULT_TO = ""
var COPY_RESULT_TO = ""
type Tag string
type Node struct {
Node string
Tags map[Tag]bool
Rowid int
}
type Index map[Tag]map[int]bool
type TreeIndex map[Tag]*TreeIndex
type State struct {
FilesInDir int
Nodes map[int]Node
Path string
TagIndex Index
LastRowid int
Tree TreeIndex
TagAsk map[Tag]string
Conf []Element_yaml
}
func (s *State) make_path_walkable(path string) string {
// Golang Walk function doesn't walk on directories specified as ~/Downloads, but walks on ~/Downloads/
// So, we shall add slash to the path ..
if !strings.HasSuffix(path, "/") {
return path + "/"
}
return path
}
func (s *State) init(path string) {
path = s.make_path_walkable(path)
s.Nodes = make(map[int]Node)
s.Path = path
s.TagIndex = make(map[Tag]map[int]bool, 0)
s.Tree = make(TreeIndex, 0)
s.TagAsk = make(map[Tag]string, 0)
s.Conf = Parse_config()
}
type Element_yaml struct {
Worker string `yaml:"Worker"`
Ask string `yaml:"Ask"`
Yes string `yaml:"Yes"`
Items []string `yaml:"Items"`
}
type WorkerReturn struct {
Tag Tag
TagAsk string
}
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
s := State{}
path := flag.String("p", "./", "Enter a dir, that you want to akinate")
temp_mv := flag.String("mv", "", "Place a folder name where you want to move result")
temp_cp := flag.String("cp", "", "Place a folder name where you want to copy result")
is_debug := flag.Bool("debug", false, "Print debug info")
flag.Parse()
MOVE_RESULT_TO = *temp_mv
COPY_RESULT_TO = *temp_cp
s.init(*path)
s.Walk()
s.build_tree()
if *is_debug {
s.walk_tree(s.Tree, "-")
}
result_set := make(map[Tag]bool)
s.Akinate(s.Tree, result_set)
}