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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
package main
import (
"bytes"
"fmt"
//"os"
"io/ioutil"
//"strconv"
"github.com/BurntSushi/toml"
)
type Config struct {
Database string //`toml:"database"`
Name string //`toml:"name"`
Street string //`toml:"street"`
Zip string //`toml:"zip"`
City string //`toml:"city"`
Country string //`toml:"country"`
Telefon string //`toml:"telefon"`
Mobile string //`toml:"mobile"`
Mail string //`toml:"mail"`
Url string //`toml:"url"`
Taxid string //`toml:"taxid"`
Bankacc string //`toml:"bankacc"`
Banklz string //`toml:"banklz"`
Bankname string //`toml:"bankname"`
Iban string //`toml:"iban"`
Bic string //`toml:"bic"`
}
var conffile string
var config Config
func init() {
conffile = "laboravi.config.toml"
}
func editConf() {
for {
if _, err := toml.DecodeFile(conffile, &config); err != nil {
//fmt.Println(err)
fmt.Println("Configuration file not found")
makeNewTOML(false)
}else{
showConfig()
if isSure("Is this Configuration Correct?") {
break
}else{
//if isSure("Enter new Configuration?"){
makeNewTOML(true)
//}else{
// fmt.Println("I Really Dont think I can Help You then...!")
//}
}
}
}
}
func initConf() {
for {
if _, err := toml.DecodeFile(conffile, &config); err != nil {
//fmt.Println(err)
fmt.Println("Configuration file not found")
makeNewTOML(false)
}else{
fmt.Println("Configuration loaded Successfully")
break
}
}
}
func makeNewTOML(gibts bool) {
if gibts {
fmt.Println("Editing Configuration File\nPress [Enter] to keep the Current setting")
}else{
fmt.Println("Making new Configuration File")
//arr := []string{"", "", ""}
//ma0 := MailAccount{"","","",0,"",""}
//mm0 := MassMail{"","","",arr,""}
//Examplenames Coming soon
n := ""
config = Config{"mytimes.db",n,n,n,n,n,n,n,n,n,n,n,n,n,n,n}
}
//fmt.Println("Whats Your Namecount\n")
database := getNewInput("DB File Path: ",config.Database)
name := getNewInput("Whats your Name?: ",config.Name)
street := getNewInput("Street: ",config.Street)
zip := getNewInput("Zip Code: ",config.Zip)
city := getNewInput("City: ",config.City)
country := getNewInput("Country: ",config.City)
telefon := getNewInput("Telefone number: ",config.Telefon)
mobile := getNewInput("Mobile number: ",config.Mobile)
mail := getNewInput("Email: ",config.Mail)
url := getNewInput("URL: ",config.Url)
taxid := getNewInput("Tax ID: ",config.Taxid)
bankname := getNewInput("Bank Name: ",config.Bankname)
bankacc := getNewInput("Bank Account: ",config.Bankacc)
banklz := getNewInput("BLZ: ",config.Banklz)
iban := getNewInput("IBAN: ",config.Iban)
bic := getNewInput("BIC: ",config.Bic)
conf := Config{database,name,street,zip,city,country,telefon,mobile,mail,url,taxid,bankacc,banklz,bankname,iban,bic}
buf := new(bytes.Buffer)
err = toml.NewEncoder(buf).Encode(conf)
if err != nil {
panic(err)
}else{
//fmt.Println("Conffile:\n",buf.String())
fmt.Println("Writing Configuration File")
err = ioutil.WriteFile(conffile, buf.Bytes(), 0644)
checkErr(err)
}
}
func showConfig() {
buf := new(bytes.Buffer)
err := toml.NewEncoder(buf).Encode(config)
if err != nil {
panic(err)
}else{
fmt.Println("Configuration:\n",buf.String())
//fmt.Println(config)
}
}
|