-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
main.go
80 lines (64 loc) · 1.13 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
// Copyright © 2022 Bjørn Erik Pedersen <[email protected]>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"log"
"os"
"runtime/debug"
"github.com/bep/s3deploy/v2/lib"
)
var (
commit = "none"
tag = "(devel)"
date = "unknown"
)
func main() {
log.SetFlags(0)
if err := parseAndRun(os.Args[1:]); err != nil {
log.Fatal(err)
}
}
func parseAndRun(args []string) error {
cfg, err := lib.ConfigFromArgs(args)
if err != nil {
return err
}
initVersionInfo()
if !cfg.Silent {
fmt.Printf("s3deploy %v, commit %v, built at %v\n", tag, commit, date)
}
if cfg.Help {
cfg.Usage()
return nil
}
if cfg.PrintVersion {
return nil
}
stats, err := lib.Deploy(cfg)
if err != nil {
return err
}
if !cfg.Silent {
fmt.Println(stats.Summary())
}
return nil
}
func initVersionInfo() {
bi, ok := debug.ReadBuildInfo()
if !ok {
return
}
for _, s := range bi.Settings {
switch s.Key {
case "vcs":
case "vcs.revision":
commit = s.Value
case "vcs.time":
date = s.Value
case "vcs.modified":
}
}
}