Skip to content

Commit 459dd28

Browse files
authored
Merge pull request #216 from jonludlam/clis
Fix the memory CLI and add a network one
2 parents 468175a + 0270f4e commit 459dd28

File tree

5 files changed

+54
-3
lines changed

5 files changed

+54
-3
lines changed

gpumon/gpumon_cli.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ let cli () =
1919
let rpc = Gpumon_client.rpc in
2020
Cmdliner.Term.eval_choice default_cmd (List.map (fun t -> t rpc) (Cmds.implementation ()))
2121

22-
let _ = cli ()
22+
let _ =
23+
match cli () with
24+
| `Ok f -> f ()
25+
| _ -> ()
26+

memory/memory_cli.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ let default_cmd =
1818

1919
let cli () =
2020
let rpc = Memory_client.rpc in
21-
Cmdliner.Term.eval_choice default_cmd (List.map (fun t -> t rpc) (Cmds.implementation ()))
21+
match Cmdliner.Term.eval_choice default_cmd (List.map (fun t -> t rpc) (Cmds.implementation ())) with
22+
| `Ok f -> f ()
23+
| _ -> ()
2224

2325
let _ = cli ()

network/jbuild

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,26 @@ let () = Printf.ksprintf Jbuild_plugin.V1.send {|
3131
((name xcp_network)
3232
(public_name xcp.network)
3333
(flags (:standard -w -39-33 %s))
34+
(modules (:standard \ network_cli))
3435
(libraries
3536
(rpclib
3637
threads
3738
xcp))
3839
(wrapped false)
3940
%s))
4041

42+
(executable
43+
((name network_cli)
44+
(modules (network_cli))
45+
(libraries
46+
(cmdliner
47+
rpclib.cmdliner
48+
rpclib.markdown
49+
xcp.network))))
50+
51+
(alias
52+
((name runtest)
53+
(deps (network_cli.exe))
54+
(action (run ${<}))))
55+
4156
|} (flags rewriters_ppx) coverage_rewriter

network/network_cli.ml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
(* Network CLI *)
2+
3+
open Network_interface
4+
5+
module Cmds = Interface_API(Cmdlinergen.Gen ())
6+
7+
let version_str description =
8+
let maj,min,mic = description.Idl.Interface.version in
9+
Printf.sprintf "%d.%d.%d" maj min mic
10+
11+
let default_cmd =
12+
let doc = String.concat "" [
13+
"A CLI for the network API. This allows scripting of the xcp-networkd daemon ";
14+
"for testing and debugging. This tool is not intended to be used as an ";
15+
"end user tool"] in
16+
Cmdliner.Term.(ret (const (fun _ -> `Help (`Pager, None)) $ const ())),
17+
Cmdliner.Term.info "network_cli" ~version:(version_str Cmds.description) ~doc
18+
19+
let cli () =
20+
let rpc = Network_client.rpc in
21+
Cmdliner.Term.eval_choice default_cmd (List.map (fun t -> t rpc) (Cmds.implementation ()))
22+
23+
let _ =
24+
match cli () with
25+
| `Ok f -> f ()
26+
| _ -> ()

v6/v6_cli.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ let cli () =
1818
let rpc = V6_client.rpc in
1919
Cmdliner.Term.eval_choice default_cmd (List.map (fun t -> t rpc) (Cmds.implementation ()))
2020

21-
let _ = cli ()
21+
let _ =
22+
match cli () with
23+
| `Ok f -> f ()
24+
| _ -> ()
25+

0 commit comments

Comments
 (0)