-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (34 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
/*
Gitback provides functionality to backup GitHub repositories either
using a GitHub Personal Access Token (PAT) or without authentication (public only).
Author: FlareXes
License: BSD-3-Clause
Project: https://github.com/flarexes/gitback/
*/
package main
import (
"flag"
"log"
"os"
"github.com/flarexes/gitback/vcs"
)
func main() {
noauth := flag.Bool("noauth", false, "Disable GitHub Auth, Limited to 60 Request/Hr & Public Data")
username := flag.String("username", "", "Required When --noauth is Set")
threads := flag.Int("threads", 10, "Maximum number of concurrent connections")
token := flag.String("token", "", "GitHub API Token")
flag.Parse()
if *noauth && *username == "" {
log.Println("Error: when --noauth is set, --username is required")
log.Fatal("Usage: gitback --noauth --username flarexes")
}
if *threads <= 1 {
log.Fatal("Error: --threads must be a positive integer")
}
if *token != "" {
if err := os.Setenv("GITHUB_PERSONAL_ACCESS_TOKEN", *token); err != nil {
log.Fatal("Error setting environment variable:", err)
}
}
vcs.Run(*noauth, *username, *threads)
}