Replace Cmdliner with Ocmd, re-add documentation

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

git-svn-id: file:///srv/svn/repo/kosuzu/trunk@65 eb64cd80-c68d-6f47-b6a3-0ada418499da
This commit is contained in:
yakumo.izuru
2024-08-20 13:17:24 +00:00
parent 970ca9da7e
commit 3f090772ce
30 changed files with 218 additions and 26 deletions

View File

@@ -6,7 +6,7 @@ let authors r topics_opt =
let s = File_store.fold ~r ~predicate author_union Person.Set.empty in
Person.Set.iter (fun x -> print_endline (Person.to_string x)) s
open Cmdliner
open Ocmd
let term =
let recurse = Arg.(value & flag & info ["R"]
~doc:"include texts in subdirectories too") in

View File

@@ -76,7 +76,7 @@ let at_path types noindex path = match path with
)
| path -> Printf.eprintf "Path doesn't exist: %s" path
open Cmdliner
open Ocmd
let term =
let path = Arg.(value & pos 0 string "" & info [] ~docv:"path"
~doc:"Text file or directory to convert. If directory is provided, it must contain an index.pck (see: txt index)") in

View File

@@ -1,4 +1,4 @@
open Cmdliner
open Ocmd
let term =
let id = Arg.(value & pos 0 string "" & info [] ~docv:"text ID") in
let recurse = Arg.(value & flag & info ["R"] ~doc:"recurse, include subdirs") in

View File

@@ -14,7 +14,7 @@ let unfile files =
with Unix.(Unix_error(ENOENT,_,_))-> () in
List.iter (fun d -> List.iter (unlink d) files) dirs
open Cmdliner
open Ocmd
let term =
let files = Arg.(value & pos_all string [] & info []
~docv:"text filenames and subdirectories") in

View File

@@ -67,7 +67,7 @@ let load dir =
let index_path = Filename.concat dir "index.pck" in
index { dir; index_path; pck = Header_pack.of_kv kv }
open Cmdliner
open Ocmd
let term =
let print= Arg.(value & flag & info ["print"] ~doc:"print info") in
let title= Arg.(value & opt ~vopt:(Some "") (some string) None & info ["t"; "title"]

View File

@@ -20,7 +20,7 @@ let last search_mine =
| None -> ()
| Some (_, f) -> List.iter print_endline f
open Cmdliner
open Ocmd
let term =
let mine = Arg.(value & flag & info ["mine"] ~doc:"last text authored by me") in
Term.(const last $ mine),

View File

@@ -19,7 +19,7 @@ let listing r order_opt reverse_opt number_opt paths_opt authors_opt topics_opt
| Some number -> FS.iter ~r ~dir ~predicate ~order ~number list_text
| None -> FS.iter ~r ~dir ~predicate ~order list_text
open Cmdliner
open Ocmd
let term =
let recurse = Arg.(value & flag & info ["R"] ~doc:"recurse, include subdirs") in
let reverse = Arg.(value & flag & info ["r"] ~doc:"reverse order") in

View File

@@ -1,5 +1,5 @@
open Logarion
open Cmdliner
open Ocmd
let new_txt title topics_opt interactive =
let kv = Logarion.File_store.of_kv_file () in

View File

@@ -28,7 +28,7 @@ let peers = function
Printf.printf "Peers in %s\n" Logarion.Peers.text_dir;
Logarion.Peers.fold print_peer ()
open Cmdliner
open Ocmd
let term =
let remove = Arg.(value & opt (some string) None & info ["remove"]
~docv:"repository ID" ~doc:"remove repository texts & from future pulling") in

View File

@@ -138,7 +138,7 @@ let pull_list auths topics =
let pull url auths topics = match url with
| "" -> pull_list auths topics | x -> ignore (pull_index x auths topics)
open Cmdliner
open Ocmd
let term =
let authors = Arg.(value & opt (some string) None & info ["a"; "authors"]
~docv:"comma-separated names" ~doc:"filter by authors") in

View File

@@ -1,6 +1,6 @@
open Logarion
open Cmdliner
open Ocmd
let term =
let id = Arg.(value & pos 0 string "" & info [] ~docv:"text ID") in
let recurse = Arg.(value & flag & info ["R"] ~doc:"recurse, include subdirs") in

View File

@@ -2,7 +2,7 @@ open Logarion
module FS = File_store
module A = Archive
open Cmdliner
open Ocmd
let term =
let recurse = Arg.(value & flag & info ["R"] ~doc:"recurse, include subdirs") in
let reverse = Arg.(value & flag & info ["r"] ~doc:"reverse order") in

View File

@@ -6,7 +6,7 @@ let topics r authors_opt =
let s = File_store.fold ~r ~predicate topic_union String_set.empty in
print_endline @@ String_set.to_string s
open Cmdliner
open Ocmd
let term =
let recurse = Arg.(value & flag & info ["R"]
~doc:"include texts in subdirectories") in

View File

@@ -1,10 +1,8 @@
let version = "1.3.2"
open Cmdliner
open Ocmd
let default_cmd =
let doc = "Discover, collect & exchange texts" in
let man = [ `S "CONTACT"; `P "<mailto:logarion-dev@chaotic.ninja>" ] in
Term.(ret (const (`Help (`Pager, None)))), Term.info "txt" ~version ~doc ~man
Term.(ret (const (`Help (`Pager, None)))), Term.info "txt" ~version:"%%VERSION%%" ~doc ~man
let () = match Term.eval_choice default_cmd [
Authors.term;