feat(CA): create author function (required for gh command)

This commit is contained in:
Slug-Boi
2025-04-04 19:44:55 +02:00
parent d70825da65
commit 97f514ccce
+32
View File
@@ -73,6 +73,38 @@ func CheckAuthorFile() string {
return authorfile return authorfile
} }
func CreateAuthor(user User) {
Users[user.Shortname] = user
Users[user.Longname] = user
// Specifically for the json file
Authors.Authors[user.Longname] = user
data, err := json.MarshalIndent(Authors, "", " ")
if err != nil {
panic(fmt.Sprintf("Error marshalling json: %v", err))
}
// open author_file
author_file := Find_authorfile()
f, err := os.OpenFile(author_file, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
panic(err)
}
defer f.Close()
// write the data to the file
f.Truncate(0)
f.Seek(0, 0)
f.Write(data)
f.Close()
// redefine the users map for the tui to use
Define_users(Find_authorfile())
}
func DeleteOneAuthor(author string) { func DeleteOneAuthor(author string) {
author_file := Find_authorfile() author_file := Find_authorfile()