-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
61 lines (54 loc) · 1.17 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
package main
import (
"flag"
"fmt"
"log"
"os"
"path/filepath"
"github.com/qawatake/obsdconv/process"
)
var (
Version = "x.y.z"
)
const (
DEFAULT_IGNORE_FILE_NAME = ".obsdconvignore"
)
func main() {
// config を設定
config := new(configuration)
initFlags(flag.CommandLine, config)
flag.Parse()
setConfig(flag.CommandLine, config)
// main 部分
versionText, bufferredErrs, err := run(Version, config)
if err != nil {
log.Fatal(err)
}
if versionText != "" {
fmt.Println(versionText)
return
}
for _, err := range bufferredErrs {
fmt.Fprintln(os.Stderr, err)
}
}
func run(version string, config *configuration) (verionText string, bufferredErrs []error, err error) {
if config.ver {
return fmt.Sprintf("v%s", version), nil, nil
}
if err := verifyConfig(config); err != nil {
return "", nil, err
}
skipper, err := process.NewSkipper(filepath.Join(config.src, DEFAULT_IGNORE_FILE_NAME))
if err != nil {
return "", nil, err
}
processor, err := newDefaultProcessor(config)
if err != nil {
return "", nil, err
}
if err := process.Walk(config.tgt, config.dst, skipper, processor); err != nil {
return "", nil, err
}
return "", processor.errbuf, nil
}