Commit 725263cd authored by Fardale's avatar Fardale

use cmdliner

parent fbe8d4bd
......@@ -75,7 +75,7 @@ let server_handler pass port sockaddr (ic, oc) =
let stop_server resolver server _ = Lwt.wakeup_later resolver server
let main pass port =
let node pass port =
let promise, resolver = Lwt.task () in
let template = "$(date).$(milliseconds) $(name)[$(pid)]: $(message)" in
Lwt_log.file ~template ~perm:0o600 ~file_name:"test.log" ()
......@@ -89,18 +89,38 @@ let main pass port =
open Cmdliner
let _ =
let node_cmd =
let port =
let doc = "port on which client listen" in
Arg.(value & opt int 4242 & info ["p"; "port"] ~docv:"PORT" ~doc) in
let info =
let doc = "Transforme un pool of computer into a cluster." in
let man = [
`S Manpage.s_bugs;
`P "Email bug reports to <fardale+ocluster at crans.org>." ]
in
Term.info "ocluster" ~version:"%%VERSION%%" ~doc ~exits:Term.default_exits ~man
Arg.(value & opt int 4242 & info ["p"; "port"] ~docv:"PORT" ~doc)
in
Lwt_main.run (main "plopissecured" 2121)
let pass =
let doc = "Password of the node" in
Arg.(required & pos 0 (some string) None & info [] ~docv:"PASS"
~doc)
in
let doc = "Start un compatational node" in
let exits = Term.default_exits in
let man =
[`S Manpage.s_description;
`P "Start un compatational node on port $(port) with the password $(pass)";]
in
Term.(const Lwt_main.run $ (const node $ pass $ port)),
Term.info "node" ~doc ~sdocs:Manpage.s_common_options ~exits ~man
let default_cmd =
let doc = "Transforme un pool of computer into a cluster." in
let man = [
`S Manpage.s_bugs;
`P "Email bug reports to <fardale+ocluster at crans.org>." ]
in
let sdocs = Manpage.s_common_options in
let exits = Term.default_exits in
Term.(ret (const (fun _ -> `Help (`Pager, None)) $ const ())),
Term.info "ocluster" ~version:"v0.0.1" ~doc ~sdocs ~exits ~man
let () = Term.(exit @@ eval_choice default_cmd [node_cmd])
(*Lwt_io.with_connection (Lwt_unix.ADDR_INET (Unix.inet_addr_of_string "127.0.0.1", 2121)) (fun (ic,oc) -> Lwt_io.write_value oc (COMPUTATION {id = 0; script = "#echo penis\necho plop\nls"; time = None; pass = "wesh"}));;*)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment