Add txt-init program

Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>

git-svn-id: file:///srv/svn/repo/kosuzu/trunk@71 eb64cd80-c68d-6f47-b6a3-0ada418499da
This commit is contained in:
yakumo.izuru 2024-08-21 16:57:44 +00:00
parent 02fb238de3
commit 027d87262e
3 changed files with 49 additions and 0 deletions

2
.gitignore vendored
View File

@ -9,3 +9,5 @@
_build
*.htm
index.html
/.svn
/txt-init

44
cli/txt-init/main.go Normal file
View File

@ -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 <protocol:name@example.com> 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)
}

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module git.chaotic.ninja/logarion
go 1.21.12