Migrate the codebase to the latest revision of Cmdliner
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja> git-svn-id: file:///srv/svn/repo/kosuzu/trunk@66 eb64cd80-c68d-6f47-b6a3-0ada418499da
This commit is contained in:
57
cli/pull.ml
57
cli/pull.ml
@@ -138,47 +138,18 @@ 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 Ocmd
|
||||
let term =
|
||||
let authors = Arg.(value & opt (some string) None & info ["a"; "authors"]
|
||||
~docv:"comma-separated names" ~doc:"filter by authors") in
|
||||
let topics = Arg.(value & opt (some string) None & info ["t"; "topics"]
|
||||
~docv:"comma-separated topics" ~doc:"filter by topics") in
|
||||
let url = Arg.(value & pos 0 string "" & info [] ~docv:"URL"
|
||||
~doc:"Repository location") in
|
||||
Term.(const pull $ url $ authors $ topics),
|
||||
Term.info "pull" ~doc:"pull listed texts" ~man:[ `S "DESCRIPTION";
|
||||
`P "Pull texts from known repositories. To add a new repository use:";
|
||||
`P "txt pull [url]";
|
||||
`P ("This creates a directory in " ^ Logarion.Peers.text_dir
|
||||
^ " and downloads the text index.pck file in it")]
|
||||
open Cmdliner
|
||||
let authors = Arg.(value & opt (some string) None & info ["a"; "authors"] ~docv:"Comma-separated names" ~doc:"Filter by authors")
|
||||
let topics = Arg.(value & opt (some string) None & info ["t"; "topics"] ~docv:"Comma-separated topics" ~doc:"Filter by topics")
|
||||
let url = Arg.(value & pos 0 string "" & info [] ~docv:"URL" ~doc:"Repository location")
|
||||
|
||||
(*module Msg = struct*)
|
||||
(* type t = string * string*)
|
||||
(* let compare (x0,y0) (x1,y1) =*)
|
||||
(* match compare x1 x0 with 0 -> String.compare y0 y1 | c -> c*)
|
||||
(*end*)
|
||||
(*module MsgSet = Set.Make(Msg)*)
|
||||
(*let pull_msgs url _authors _topics =*)
|
||||
(* match http_apply response url with*)
|
||||
(* | Error msg ->*)
|
||||
(* Printf.eprintf "Failed index request for %s %s" url msg*)
|
||||
(* | Ok body ->*)
|
||||
(* let rec fold_msgs s a fn =*)
|
||||
(* let t, msg = Scanf.bscanf s "%s %s@\n" (fun t m -> t, m) in*)
|
||||
(* if t <> "" then fold_msgs s (fn a t msg) fn else a*)
|
||||
(* in*)
|
||||
(* let s = Scanf.Scanning.from_string body in*)
|
||||
(* let msgs = MsgSet.empty in*)
|
||||
(* let date_string t = Ptime.to_date t |>*)
|
||||
(* fun (y, m, d) -> Printf.sprintf "%04d-%02d-%02d" y m d in*)
|
||||
(* let msgs = fold_msgs s msgs*)
|
||||
(* (fun msgs t m -> match Ptime.of_rfc3339 t with*)
|
||||
(* | Ok (v,_,_) -> let open MsgSet in*)
|
||||
(* let msgs = if cardinal msgs > 1 then remove (max_elt msgs) msgs else msgs in*)
|
||||
(* add (v,m) msgs*)
|
||||
(* | _ -> msgs) in*)
|
||||
(* let msg_string = MsgSet.fold*)
|
||||
(* (fun (t,m) a -> a ^ Printf.sprintf " %s 𐄁 %s\n" (date_string t) m)*)
|
||||
(* msgs "" in*)
|
||||
(* Printf.printf "┌───{ %s }───┐\n%s" url msg_string*)
|
||||
let pull_t = Term.(const pull $ url $ authors $ topics)
|
||||
|
||||
let cmd =
|
||||
let doc = "Pull listed texts" in
|
||||
let man = [
|
||||
`S Manpage.s_description;
|
||||
`P "Pull texts from known repositories." ]
|
||||
in
|
||||
let info = Cmd.info "pull" ~version:"%%VERSION%%" ~doc ~man in
|
||||
Cmd.v info pull_t
|
||||
|
||||
Reference in New Issue
Block a user