Reimplemented txt-init in OCaml
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja> git-svn-id: https://svn.yakumo.dev/yakumo.izuru/kosuzu/trunk@72 eb64cd80-c68d-6f47-b6a3-0ada418499da
This commit is contained in:
parent
583f725b21
commit
6e97efbf0c
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,4 +10,3 @@ _build
|
|||||||
*.htm
|
*.htm
|
||||||
index.html
|
index.html
|
||||||
/.svn
|
/.svn
|
||||||
/txt-init
|
|
||||||
|
@ -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 <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)
|
|
||||||
}
|
|
||||||
|
|
4
init/dune
Normal file
4
init/dune
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
(executable
|
||||||
|
(name init)
|
||||||
|
(public_name txt_init)
|
||||||
|
(libraries logarion))
|
18
init/init.ml
Normal file
18
init/init.ml
Normal file
@ -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 <name@email> <http://website>): ";
|
||||||
|
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
|
@ -1,6 +1,6 @@
|
|||||||
# This file is generated by dune, edit dune-project instead
|
# This file is generated by dune, edit dune-project instead
|
||||||
opam-version: "2.0"
|
opam-version: "2.0"
|
||||||
version: "1.4.2"
|
version: "1.4.3"
|
||||||
synopsis: "Texts archival and exchange"
|
synopsis: "Texts archival and exchange"
|
||||||
maintainer: ["Izuru Yakumo <yakumo.izuru@chaotic.ninja>"]
|
maintainer: ["Izuru Yakumo <yakumo.izuru@chaotic.ninja>"]
|
||||||
authors: ["orbifx <fox@orbitalfox.eu>"]
|
authors: ["orbifx <fox@orbitalfox.eu>"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user