source: code/trunk/cli/peers.ml@ 52

Last change on this file since 52 was 42, checked in by fox, 2 years ago

Preliminary support for cross-domain references

File size: 1.3 KB
Line 
1let print_peers_of_peer p =
2 let open Logarion.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
7type filter_t = { authors: Logarion.Person.Set.t; topics: Logarion.String_set.t }
8
9let print_peer () peer =
10 let open Logarion.Peers in
11 Printf.printf "%s" peer.path;
12 List.iter (Printf.printf "\t%s\n") peer.pack.info.locations
13
14let remove_repo id =
15 let repopath = Filename.concat Logarion.Peers.text_dir id in
16 match Sys.is_directory repopath with
17 | false -> Printf.eprintf "No repository %s in %s" id Logarion.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
25let peers = function
26 | Some id -> remove_repo id
27 | None ->
28 Printf.printf "Peers in %s\n" Logarion.Peers.text_dir;
29 Logarion.Peers.fold print_peer ()
30
31open Cmdliner
32let term =
33 let remove = Arg.(value & opt (some string) None & info ["remove"]
34 ~docv:"repository ID" ~doc:"remove repository texts & from future pulling") in
35 Term.(const peers $ remove),
36 Term.info "peers" ~doc:"list current peers" ~man:[ `S "DESCRIPTION";
37 `P "Lists current peers and associated information"]
Note: See TracBrowser for help on using the repository browser.