This commit is contained in:
parent
f0847855bd
commit
437638c4a1
3 changed files with 39 additions and 2 deletions
|
|
@ -2,4 +2,4 @@
|
|||
(public_name offline)
|
||||
(name offline)
|
||||
(modules offline)
|
||||
(libraries cmdliner bos fmt mirage-crypto ptime mte))
|
||||
(libraries cmdliner bos fmt mirage-crypto ptime mte vif))
|
||||
|
|
|
|||
|
|
@ -1 +1,38 @@
|
|||
let () = Fmt.pr "hello~@."; ()
|
||||
let download ~base_url ~output_file =
|
||||
let open Bos in
|
||||
let uri =
|
||||
Uri.with_path (Uri.of_string base_url) "/management/keys/" |> Uri.to_string
|
||||
in
|
||||
let wget = Cmd.(v "wget" % "-O" % output_file % uri) in
|
||||
match OS.Cmd.run wget with
|
||||
| Error (`Msg err) ->
|
||||
Fmt.epr "Download failure: %s@." err;
|
||||
exit 1
|
||||
| Ok () -> ()
|
||||
|
||||
(* CLI *)
|
||||
|
||||
open Cmdliner
|
||||
open Cmdliner.Term.Syntax
|
||||
|
||||
let output =
|
||||
let doc = "File to save data to be signed." in
|
||||
Arg.(
|
||||
value & opt filepath "management_keys.json" & info [ "o"; "output" ] ~doc)
|
||||
|
||||
let base_url =
|
||||
let doc = "Base url of the exchange." in
|
||||
Arg.(value & opt string "http://localhost:3434/" & info [ "base-url" ] ~doc)
|
||||
|
||||
let download_cmd =
|
||||
let doc = "Downloads /management/keys/" in
|
||||
let man =
|
||||
[ `S Manpage.s_description; `P "$(cmd) download /management/keys." ]
|
||||
in
|
||||
Cmd.make (Cmd.info "offline" ~version:"%%VERSION%%" ~doc ~man)
|
||||
@@
|
||||
let+ output_file = output and+ base_url = base_url in
|
||||
download ~base_url ~output_file
|
||||
|
||||
let main () = Cmd.eval download_cmd
|
||||
let () = if !Sys.interactive then () else exit (main ())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue