This commit is contained in:
swrup 2026-02-10 14:51:09 +01:00
parent a0340bd100
commit 77cc2bd31e
3 changed files with 25 additions and 25 deletions

View file

@ -1,5 +1,5 @@
(* TODO
change download_cmd/upload_cmd
better cmd doc
change arguments: '_' -> '-'
all management operations:
@ -99,8 +99,8 @@ let download_cmd =
let doc = "GET" in
Cmd.make (Cmd.info "download" ~doc)
@@
let+ output = output in
download ~output
let+ output = output and+ url = url in
download ~output ~url
let upload_cmd =
let doc = "POST" in

View file

@ -161,18 +161,13 @@ let read_master_key_file filename =
let* master_key = read_file filename in
Crypto.EddsaPrivateKey.of_octets master_key
let base_url = Uri.of_string "http://localhost:3434/"
let full_url path = Uri.with_path base_url path |> Uri.to_string
let download ~output =
let download ~output ~url =
let open Bos in
let uri = full_url "/management/keys/" in
OS.Cmd.run Cmd.(v "curl" % "-s" % "-o" % output % "-X" % "GET" % uri)
OS.Cmd.run Cmd.(v "curl" % "-s" % "-o" % output % "-X" % "GET" % url)
|> unwrap_err_msg
let upload ~input ~url =
let open Bos in
let uri = full_url url in
OS.Cmd.run
Cmd.(
v "curl"
@ -183,7 +178,7 @@ let upload ~input ~url =
% "Content-Type: application/json"
% "--data"
% ("@" ^ input)
% uri)
% url)
|> unwrap_err_msg
let setup ~output =