-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
54 lines (46 loc) · 1.09 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
package main
import (
"fmt"
"os"
"whatno.io/batchrename/brp"
"whatno.io/batchrename/repl"
"whatno.io/batchrename/util"
)
func main() {
var files []*brp.FileHistory
parser, err := brp.CliParser(os.Args[1:]...)
if err != nil {
fmt.Println(err)
return
}
if parser.GetValue("help").(bool) {
fmt.Println("usage:", parser.Usage)
return
}
if parser.GetValue("version").(bool) {
fmt.Println(util.Version)
return
}
var filenames []string = parser.GetValue("filenames").([]string)
if len(filenames) == 0 {
fmt.Println("need files to rename... silly")
return
}
for _, filename := range filenames {
files = append(files, brp.NewFileHistory(filename))
}
var autofiles []string = parser.GetValue("autos").([]string)
brp.DoAutofiles(parser, autofiles, files)
var exit bool = false
for {
cmd, args := brp.Command(parser)
exit = brp.RunCmd(cmd, args, parser, files)
if exit {
break
}
switch cmd.Id {
case repl.CaseCmd, repl.AppendCmd, repl.PrependCmd, repl.UndoCmd, repl.ReplaceCmd, repl.ExtCmd, repl.InsertCmd, repl.AutoCmd, repl.DeleteCmd:
brp.DoList(files)
}
}
}