This commit is contained in:
swrup 2025-11-28 11:08:43 +01:00
parent f0847855bd
commit b21c2be6dc
2 changed files with 39 additions and 2 deletions

View file

@ -2,4 +2,4 @@
(public_name offline) (public_name offline)
(name offline) (name offline)
(modules offline) (modules offline)
(libraries cmdliner bos fmt mirage-crypto ptime mte)) (libraries cmdliner bos fmt mirage-crypto ptime mte vif))

View file

@ -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
OS.Cmd.run wget
(* 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
match download ~base_url ~output_file with
| Error (`Msg err) ->
Fmt.epr "Download failure: %s@." err;
exit 1
| Ok () -> ()
let main () = Cmd.eval download_cmd
let () = if !Sys.interactive then () else exit (main ())