This repository has been archived by the owner on Jul 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
64 lines (53 loc) · 1.58 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
package main
import (
"flag"
"fmt"
"log"
"os"
"strconv"
"github.com/thibaultserti/badges/cryptohack"
"github.com/thibaultserti/badges/newbiecontest"
"github.com/thibaultserti/badges/rootme"
)
func contains(s []string, e string) bool {
for _, a := range s {
if a == e {
return true
}
}
return false
}
func main() {
availableWebsites := map[string]([]string){"cryptohack": {"dark", "light"}, "newbiecontest": {"dark", "light"}, "rootme": {"dark", "light"}}
website := flag.String("website", "cryptohack", "Specify the challenge website from which you want to create the image (Available: cryptohack)")
username := flag.String("username", "", "Specify the username or the id (depending on the website)")
theme := flag.String("theme", "dark", "Specify the theme")
filename := flag.String("output", "", "Image output name (default <website>.png")
flag.Parse()
if len(availableWebsites[*website]) == 0 {
fmt.Println("Website not supported")
os.Exit(1)
}
if *username == "" {
fmt.Println("Username not defined")
os.Exit(1)
}
if *filename == "" {
*filename = *website + ".png"
}
if !contains(availableWebsites[*website], *theme) {
fmt.Println("Theme not supported for this website")
os.Exit(1)
}
if *website == "newbiecontest" {
id, err := strconv.Atoi(*username)
if err != nil {
log.Fatal(err)
}
newbiecontest.CreateNewbiecontestBadge(id, *theme, *filename)
} else if *website == "cryptohack" {
cryptohack.CreateCryptohackBadge(*username, *theme, *filename)
} else if *website == "rootme" {
rootme.CreateRootmeBadge(*username, *theme, *filename)
}
}