-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboris.go
62 lines (49 loc) · 1.97 KB
/
boris.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
package main
import (
"flag"
"fmt"
"github.com/JosephCaillet/boris/log"
"github.com/JosephCaillet/boris/musicorganizer"
)
func main() {
var configFile string
var showDefaultConfig bool
conf := musicorganizer.GetConfig()
flag.Usage = borisUsage
flag.StringVar(&configFile, "c", "", "config file")
flag.BoolVar(&showDefaultConfig, "s", false, "show default config, in hjson config file format")
flag.StringVar(&conf.MusicIn, "i", conf.MusicIn, "input music directory")
flag.StringVar(&conf.MusicOut, "o", conf.MusicOut, "output music directory")
flag.StringVar(&conf.UnorganizedFiles, "u", conf.UnorganizedFiles, "unorganized files directory where folders will be moved if they contains files that does not have any tags")
flag.BoolVar(&conf.Preview, "p", false, "preview change")
flag.BoolVar(&conf.Move, "m", false, "move file instead of copying them")
flag.BoolVar(&conf.DeleteMusicIn, "d", false, "delete input music folder after organizing")
flag.StringVar(&conf.Replacement, "r", conf.Replacement, "replacement for <>:\"\\/|?*")
flag.StringVar(&conf.TreeTemplate, "t", conf.TreeTemplate, "organizing template")
flag.Parse()
if showDefaultConfig {
musicorganizer.PrintDefaultConfiguration()
return
}
if configFile != "" {
if err := musicorganizer.LoadConfigurationFromFile(configFile); err != nil {
log.Error("failure loading configuration", err)
return
}
flag.Parse() //needed to overide config file by command line
}
if err := musicorganizer.Reorganize(); err != nil {
log.Error("failure reorganizing files", err)
}
}
func borisUsage() {
fmt.Fprintf(flag.CommandLine.Output(), "Usage: boris [options]\n")
fmt.Println("\nOptions:")
flag.PrintDefaults()
fmt.Print(`
About boris:
boris is a tool to reorganize automatically your music library, using tags defined in your music files and templating.
boris is made by Joseph Caillet and is released under GPL-3.0.
View source code, report bug, contribute here: https://github.com/JosephCaillet/boris.
`)
}