Changeset 66 in code for trunk/cli/pull.ml
- Timestamp:
- Aug 21, 2024, 1:37:05 AM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli/pull.ml
r65 r66 139 139 | "" -> pull_list auths topics | x -> ignore (pull_index x auths topics) 140 140 141 open Ocmd 142 let term = 143 let authors = Arg.(value & opt (some string) None & info ["a"; "authors"] 144 ~docv:"comma-separated names" ~doc:"filter by authors") in 145 let topics = Arg.(value & opt (some string) None & info ["t"; "topics"] 146 ~docv:"comma-separated topics" ~doc:"filter by topics") in 147 let url = Arg.(value & pos 0 string "" & info [] ~docv:"URL" 148 ~doc:"Repository location") in 149 Term.(const pull $ url $ authors $ topics), 150 Term.info "pull" ~doc:"pull listed texts" ~man:[ `S "DESCRIPTION"; 151 `P "Pull texts from known repositories. To add a new repository use:"; 152 `P "txt pull [url]"; 153 `P ("This creates a directory in " ^ Logarion.Peers.text_dir 154 ^ " and downloads the text index.pck file in it")] 141 open Cmdliner 142 let authors = Arg.(value & opt (some string) None & info ["a"; "authors"] ~docv:"Comma-separated names" ~doc:"Filter by authors") 143 let topics = Arg.(value & opt (some string) None & info ["t"; "topics"] ~docv:"Comma-separated topics" ~doc:"Filter by topics") 144 let url = Arg.(value & pos 0 string "" & info [] ~docv:"URL" ~doc:"Repository location") 155 145 156 (*module Msg = struct*) 157 (* type t = string * string*) 158 (* let compare (x0,y0) (x1,y1) =*) 159 (* match compare x1 x0 with 0 -> String.compare y0 y1 | c -> c*) 160 (*end*) 161 (*module MsgSet = Set.Make(Msg)*) 162 (*let pull_msgs url _authors _topics =*) 163 (* match http_apply response url with*) 164 (* | Error msg ->*) 165 (* Printf.eprintf "Failed index request for %s %s" url msg*) 166 (* | Ok body ->*) 167 (* let rec fold_msgs s a fn =*) 168 (* let t, msg = Scanf.bscanf s "%s %s@\n" (fun t m -> t, m) in*) 169 (* if t <> "" then fold_msgs s (fn a t msg) fn else a*) 170 (* in*) 171 (* let s = Scanf.Scanning.from_string body in*) 172 (* let msgs = MsgSet.empty in*) 173 (* let date_string t = Ptime.to_date t |>*) 174 (* fun (y, m, d) -> Printf.sprintf "%04d-%02d-%02d" y m d in*) 175 (* let msgs = fold_msgs s msgs*) 176 (* (fun msgs t m -> match Ptime.of_rfc3339 t with*) 177 (* | Ok (v,_,_) -> let open MsgSet in*) 178 (* let msgs = if cardinal msgs > 1 then remove (max_elt msgs) msgs else msgs in*) 179 (* add (v,m) msgs*) 180 (* | _ -> msgs) in*) 181 (* let msg_string = MsgSet.fold*) 182 (* (fun (t,m) a -> a ^ Printf.sprintf " %s 𐄁 %s\n" (date_string t) m)*) 183 (* msgs "" in*) 184 (* Printf.printf "┌───{ %s }───┐\n%s" url msg_string*) 146 let pull_t = Term.(const pull $ url $ authors $ topics) 147 148 let cmd = 149 let doc = "Pull listed texts" in 150 let man = [ 151 `S Manpage.s_description; 152 `P "Pull texts from known repositories." ] 153 in 154 let info = Cmd.info "pull" ~version:"%%VERSION%%" ~doc ~man in 155 Cmd.v info pull_t
Note:
See TracChangeset
for help on using the changeset viewer.