From 027d87262e0b8757106f1880de258f28b364a1ef Mon Sep 17 00:00:00 2001 From: "yakumo.izuru" Date: Wed, 21 Aug 2024 16:57:44 +0000 Subject: [PATCH] Add txt-init program Signed-off-by: Izuru Yakumo git-svn-id: file:///srv/svn/repo/kosuzu/trunk@71 eb64cd80-c68d-6f47-b6a3-0ada418499da --- .gitignore | 2 ++ cli/txt-init/main.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ go.mod | 3 +++ 3 files changed, 49 insertions(+) create mode 100644 cli/txt-init/main.go create mode 100644 go.mod diff --git a/.gitignore b/.gitignore index 6d3f01b..164ba07 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ _build *.htm index.html +/.svn +/txt-init diff --git a/cli/txt-init/main.go b/cli/txt-init/main.go new file mode 100644 index 0000000..a12d541 --- /dev/null +++ b/cli/txt-init/main.go @@ -0,0 +1,44 @@ +package main + +import ( + "fmt" + "os" +) + +var ( + authors string + id string + title string +) + +func main() { + fmt.Print("Name of the repository: ") + fmt.Scanln(&title) + fmt.Print("Base32 unique identifier (must be 6 characters long): ") + fmt.Scanln(&id) + fmt.Print("Authors (addresses in the format: ") + fmt.Scanln(&authors) + + f, err := os.Create("./txt.conf") + if err != nil { + fmt.Println("Error creating txt.conf") + os.Exit(1) + } + defer f.Close() + + pwd, err := os.Getwd() + if err != nil { + fmt.Println("Unable to get working directory") + os.Exit(1) + } + + f.WriteString("Id: " + fmt.Sprint(id) + "\n") + f.WriteString("Title: " + fmt.Sprint(title) + "\n") + f.WriteString("Authors: " + fmt.Sprint(authors) + "\n") + + fmt.Println("All done!") + fmt.Println("Configuration file written to txt.conf") + fmt.Println("Read the documentation in Logarion's repository") + fmt.Printf("%v\n", pwd) +} + diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..5d0c91f --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module git.chaotic.ninja/logarion + +go 1.21.12