From e0c0efc022d68abc79fc198725be0618c187bb9f Mon Sep 17 00:00:00 2001 From: hahwul Date: Sun, 27 Sep 2020 00:22:15 +0900 Subject: [PATCH] (#23) Update add-tools for changed data.json format --- add-tool.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/add-tool.go b/add-tool.go index 76bce95..25c6abf 100644 --- a/add-tool.go +++ b/add-tool.go @@ -21,7 +21,8 @@ template */ type Tools struct { - Type, Data, Method string + Type, Data, Method, Description string + Install, Update map[string]string } func isTitleElement(n *html.Node) bool { @@ -52,7 +53,7 @@ func GetHtmlTitle(r io.Reader) (string, bool) { return traverse(doc) } -func writeJSON(category string, name string, method string, data string) { +func writeJSON(category, name, method, data, udesc string) { jsonFile, err := os.Open("data.json") // if we os.Open returns an error then handle it if err != nil { @@ -63,11 +64,24 @@ func writeJSON(category string, name string, method string, data string) { defer jsonFile.Close() byteValue, _ := ioutil.ReadAll(jsonFile) var result map[string]interface{} + install := map[string]string{ + "MacOS":"", + "Linux":"", + "Windows":"", + } + update := map[string]string{ + "MacOS":"", + "Linux":"", + "Windows":"", + } json.Unmarshal([]byte(byteValue), &result) tool := Tools{ Type: category, Data: data, Method: method, + Description: udesc, + Install: install, + Update: update, } result[name] = tool file, _ := json.MarshalIndent(result, "", " ") @@ -140,7 +154,7 @@ func main() { fmt.Println("[+] What is method(e.g XSS, WVS, SSL, ETC..)?") method, _ := reader1.ReadString('\n') method = strings.TrimRight(method, "\r\n") - writeJSON(m[choicetype], name, method, "| "+m[choicetype]+"/"+method+" | ["+name+"]("+*repourl+") | "+desc+" | ![](https://img.shields.io/github/stars"+u.Path+") | ![](https://img.shields.io/github/languages/top"+u.Path+") |") + writeJSON(m[choicetype], name, method, "| "+m[choicetype]+"/"+method+" | ["+name+"]("+*repourl+") | "+desc+" | ![](https://img.shields.io/github/stars"+u.Path+") | ![](https://img.shields.io/github/languages/top"+u.Path+") |", desc) } else { reader := bufio.NewReader(os.Stdin) fmt.Println("[+] What is name?") @@ -178,7 +192,7 @@ func main() { fmt.Println("[+] What is method(e.g XSS, WVS, SSL, ETC..)?") method, _ := reader1.ReadString('\n') method = strings.TrimRight(method, "\r\n") - writeJSON(m[choicetype], name, method, "| "+m[choicetype]+"/"+method+" | ["+name+"]("+*repourl+") | "+udesc+"|![](https://img.shields.io/static/v1?label=&message=it's not github&color=gray)|![](https://img.shields.io/static/v1?label=&message=it's not github&color=gray)") + writeJSON(m[choicetype], name, method, "| "+m[choicetype]+"/"+method+" | ["+name+"]("+*repourl+") | "+udesc+"|![](https://img.shields.io/static/v1?label=&message=it's not github&color=gray)|![](https://img.shields.io/static/v1?label=&message=it's not github&color=gray)",udesc) } if *first {