Last change
on this file since 75 was 73, checked in by Izuru Yakumo, 8 months ago |
Because sweet girls are the best, officially rebranding Logarion to Kosuzu
Signed-off-by: Izuru Yakumo <yakumo.izuru@…>
|
File size:
1.4 KB
|
Rev | Line | |
---|
[73] | 1 | let print_peers_of_peer p =
|
---|
| 2 | let open Kosuzu.Header_pack in
|
---|
| 3 | match Msgpck.to_list p.peers with [] -> ()
|
---|
| 4 | | ps -> print_endline @@
|
---|
| 5 | List.fold_left (fun a x -> Printf.sprintf "%s %s" a (Msgpck.to_string x)) "peers: " ps
|
---|
| 6 |
|
---|
| 7 | type filter_t = { authors: Kosuzu.Person.Set.t; topics: Kosuzu.String_set.t }
|
---|
| 8 |
|
---|
| 9 | let print_peer () peer =
|
---|
| 10 | let open Kosuzu.Peers in
|
---|
| 11 | Printf.printf "%s" peer.path;
|
---|
| 12 | List.iter (Printf.printf "\t%s\n") peer.pack.info.locations
|
---|
| 13 |
|
---|
| 14 | let remove_repo id =
|
---|
| 15 | let repopath = Filename.concat Kosuzu.Peers.text_dir id in
|
---|
| 16 | match Sys.is_directory repopath with
|
---|
| 17 | | false -> Printf.eprintf "No repository %s in %s" id Kosuzu.Peers.text_dir
|
---|
| 18 | | true ->
|
---|
| 19 | let cmd = Printf.sprintf "rm -r %s" repopath in
|
---|
| 20 | Printf.printf "Run: %s ? (y/N) %!" cmd;
|
---|
| 21 | match input_char stdin with
|
---|
| 22 | |'y'-> if Sys.command cmd = 0 then print_endline "Removed" else prerr_endline "Failed"
|
---|
| 23 | | _ -> ()
|
---|
| 24 |
|
---|
| 25 | let peers = function
|
---|
| 26 | | Some id -> remove_repo id
|
---|
| 27 | | None ->
|
---|
| 28 | Printf.printf "Peers in %s\n" Kosuzu.Peers.text_dir;
|
---|
| 29 | Kosuzu.Peers.fold print_peer ()
|
---|
| 30 |
|
---|
| 31 | open Cmdliner
|
---|
| 32 | let remove = Arg.(value & opt (some string) None & info ["remove"] ~docv:"Repository ID" ~doc:"Remove repository texts and from future pulling")
|
---|
| 33 | let peers_t = Term.(const peers $ remove)
|
---|
| 34 |
|
---|
| 35 | let cmd =
|
---|
| 36 | let doc = "List current peers" in
|
---|
| 37 | let man = [
|
---|
| 38 | `S Manpage.s_description;
|
---|
| 39 | `P "List current peers and associated information" ]
|
---|
| 40 | in
|
---|
| 41 | let info = Cmd.info "peers" ~doc ~man in
|
---|
| 42 | Cmd.v info peers_t
|
---|
Note:
See
TracBrowser
for help on using the repository browser.