diff --git a/Makefile b/Makefile index 85d1fcc4..6118b993 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,11 @@ build: install: install -D _build/install/default/bin/xcp-rrdd $(DESTDIR)$(SBINDIR)/xcp-rrdd + install -D _build/install/default/bin/rrd-cli $(DESTDIR)$(SBINDIR)/rrd-cli uninstall: rm -f $(DESTDIR)$(SBINDIR)/xcp-rrdd + rm -f $(DESTDIR)$(SBINDIR)/rrd-cli clean: dune clean diff --git a/cli/dune b/cli/dune new file mode 100644 index 00000000..526b5753 --- /dev/null +++ b/cli/dune @@ -0,0 +1,12 @@ +(executable + (name rrd_cli) + (public_name rrd-cli) + (package xapi-rrdd) + (modules rrd_cli) + (libraries + cmdliner + rpclib.cmdliner + rpclib.markdown + xapi-idl.rrd + )) + diff --git a/cli/rrd_cli.ml b/cli/rrd_cli.ml new file mode 100644 index 00000000..db5b018c --- /dev/null +++ b/cli/rrd_cli.ml @@ -0,0 +1,27 @@ +(* Rrd CLI *) + +module Cmds = Rrd_interface.RPC_API (Cmdlinergen.Gen ()) + +let version_str description = + let maj, min, mic = description.Idl.Interface.version in + Printf.sprintf "%d.%d.%d" maj min mic + +let default_cmd = + let doc = + String.concat "" + [ + "A CLI for the Db monitoring API. This allows scripting of the Rrd \ + daemon " + ; "for testing and debugging. This tool is not intended to be used as an " + ; "end user tool" + ] + in + ( Cmdliner.Term.(ret (const (fun _ -> `Help (`Pager, None)) $ const ())) + , Cmdliner.Term.info "rrd-cli" ~version:(version_str Cmds.description) ~doc ) + +let cli () = + let rpc = Rrd_client.rpc in + Cmdliner.Term.eval_choice default_cmd + (List.map (fun t -> t rpc) (Cmds.implementation ())) + +let _ = cli ()