-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
48 lines (41 loc) · 949 Bytes
/
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
package main
import (
"errors"
"fmt"
"os"
"github.com/charmbracelet/git-lfs-transfer/transfer"
"github.com/rubyist/tracerx"
)
type tracerxLogger struct{}
// Log logs the given arguments if Debug is true.
func (*tracerxLogger) Log(msg string, kv ...interface{}) {
format := msg
for i := 0; i < len(kv); i += 2 {
format += " %s=%v"
}
tracerx.Printf(format, kv...)
}
var logger = new(tracerxLogger)
func init() {
tracerx.DefaultKey = "GIT"
tracerx.Prefix = "trace git-lfs-transfer: "
}
func main() {
args := os.Args
if len(args) < 2 {
fmt.Fprintln(os.Stderr, Usage())
fmt.Fprintf(os.Stderr, "expected 2 arguments, got %d\n", len(args)-1)
os.Exit(1)
}
if err := Command(os.Stdin, os.Stdout, os.Stderr, args[1:]...); err != nil {
fmt.Fprint(os.Stderr, Usage())
fmt.Fprintln(os.Stderr)
fmt.Fprintln(os.Stderr, err)
switch {
case errors.Is(err, transfer.ErrConflict):
os.Exit(1)
default:
os.Exit(2)
}
}
}