-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
100 lines (82 loc) · 2.24 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package main
import (
"fmt"
"log"
"os"
"os/exec"
// "bytes"
scan "github.com/Varunram/essentials/scan"
flags "github.com/jessevdk/go-flags"
)
var opts struct {
Listen bool `short:"l" description:"Start the generator script in rpc mode"`
Port int `short:"p" description:"The port on which the server runs on" default:"8081"`
}
func main() {
fmt.Printf("%s", "Welcome to create-openx-app\n\n")
fmt.Printf("%s", "All options are yes by default. Please press n/N for omitting specific options\n\n")
_, err := flags.ParseArgs(&opts, os.Args)
if err != nil {
log.Fatal(err)
}
if opts.Listen {
StartServer(opts.Port)
}
fmt.Printf("%s", "Enter organization name: ")
orgName, err := scan.ScanString()
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s", "Enter platform name: ")
platformName, err := scan.ScanString()
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s", "Enter the entity that you would like to send emails as: ")
emailName, err := scan.ScanString()
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s", "This template uses Stellar as the main blockchain platform but support"+
"for other blockchains will be added in the future. Do you want to add the other blockchain handlers? ")
otherBlHandlers, err := scan.ScanString()
if err != nil {
log.Fatal(err)
}
if otherBlHandlers == "n" || otherBlHandlers == "N" {
otherBlHandlers = "n"
} else {
otherBlHandlers = "y"
}
fmt.Printf("%s", "Would you like to have voting options for investors? ")
invVote, err := scan.ScanString()
if err != nil {
log.Fatal(err)
}
if invVote == "n" || invVote == "N" {
invVote = "n"
} else {
invVote = "y"
}
fmt.Printf("%s", "Would you like to have additional options for recipients? ")
recpVote, err := scan.ScanString()
if err != nil {
log.Fatal(err)
}
if recpVote == "n" || recpVote == "N" {
recpVote = "n"
} else {
recpVote = "y"
}
if platformName == "" || orgName == "" {
fmt.Printf("%s", "platform name or org name empty, quitting")
os.Exit(1)
}
fmt.Printf("%s", "\n\nRUNNING GENERATOR SCRIPT..\n\n")
// trigger the gen script
cmd, err := exec.Command("./gen.sh", orgName, platformName, invVote, recpVote, emailName, otherBlHandlers).Output()
if err != nil {
log.Fatal(err)
}
fmt.Println(string(cmd))
}