From 6e97efbf0c90175205b59c3e652ff57f5a937c33 Mon Sep 17 00:00:00 2001 From: "yakumo.izuru" Date: Thu, 22 Aug 2024 15:02:35 +0000 Subject: [PATCH] Reimplemented txt-init in OCaml Signed-off-by: Izuru Yakumo git-svn-id: https://svn.yakumo.dev/yakumo.izuru/kosuzu/trunk@72 eb64cd80-c68d-6f47-b6a3-0ada418499da --- .gitignore | 1 - cli/txt-init/main.go | 44 -------------------------------------------- go.mod | 3 --- init/dune | 4 ++++ init/init.ml | 18 ++++++++++++++++++ logarion.opam | 2 +- 6 files changed, 23 insertions(+), 49 deletions(-) delete mode 100644 cli/txt-init/main.go delete mode 100644 go.mod create mode 100644 init/dune create mode 100644 init/init.ml diff --git a/.gitignore b/.gitignore index 164ba07..7281ccd 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,3 @@ _build *.htm index.html /.svn -/txt-init diff --git a/cli/txt-init/main.go b/cli/txt-init/main.go deleted file mode 100644 index a12d541..0000000 --- a/cli/txt-init/main.go +++ /dev/null @@ -1,44 +0,0 @@ -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 deleted file mode 100644 index 5d0c91f..0000000 --- a/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module git.chaotic.ninja/logarion - -go 1.21.12 diff --git a/init/dune b/init/dune new file mode 100644 index 0000000..04e2cbd --- /dev/null +++ b/init/dune @@ -0,0 +1,4 @@ +(executable + (name init) +(public_name txt_init) +(libraries logarion)) diff --git a/init/init.ml b/init/init.ml new file mode 100644 index 0000000..d1436d4 --- /dev/null +++ b/init/init.ml @@ -0,0 +1,18 @@ +open Logarion +let init_repo = + print_endline "No txt.conf found"; + print_endline "It's required for the repository name and id."; + print_endline "Create one? (y/n)"; + match input_line stdin with + |"y"-> + let title = + print_endline "Title for repository: "; + input_line stdin in + let authors = + print_endline "Authors (format: name ): "; + input_line stdin in + Logarion.File_store.file "txt.conf" + (Printf.sprintf "Id:%s\nTitle: %s\nAuthors: %s\n" (Logarion.Id.generate ()) title authors); + Logarion.File_store.of_kv_file () + | _ -> + print_endline "Aborting..."; exit 1 diff --git a/logarion.opam b/logarion.opam index f0f64bf..9e6d99d 100644 --- a/logarion.opam +++ b/logarion.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "1.4.2" +version: "1.4.3" synopsis: "Texts archival and exchange" maintainer: ["Izuru Yakumo "] authors: ["orbifx "]