Client: add {sk,pk}_uri_param
This commit is contained in:
parent
4b2e88f97c
commit
8bc9695ad0
@ -65,6 +65,33 @@ let make_pk_uri x = x
|
|||||||
type sk_uri = Uri.t
|
type sk_uri = Uri.t
|
||||||
let make_sk_uri x = x
|
let make_sk_uri x = x
|
||||||
|
|
||||||
|
let pk_uri_param ?name ?desc params =
|
||||||
|
let name = Option.unopt ~default:"uri" name in
|
||||||
|
let desc = Option.unopt
|
||||||
|
~default:"public key\n\
|
||||||
|
Varies from one scheme to the other.\n\
|
||||||
|
Use command `list signing schemes` for more \
|
||||||
|
information." desc in
|
||||||
|
let open Clic in
|
||||||
|
param ~name ~desc (parameter (fun _ s ->
|
||||||
|
try return (make_pk_uri @@ Uri.of_string s)
|
||||||
|
with Failure s -> failwith "Error while parsing uri: %s" s))
|
||||||
|
params
|
||||||
|
|
||||||
|
let sk_uri_param ?name ?desc params =
|
||||||
|
let name = Option.unopt ~default:"uri" name in
|
||||||
|
let desc = Option.unopt
|
||||||
|
~default:"secret key\n\
|
||||||
|
Varies from one scheme to the other.\n\
|
||||||
|
Use command `list signing schemes` for more \
|
||||||
|
information." desc in
|
||||||
|
let open Clic in
|
||||||
|
param ~name ~desc
|
||||||
|
(parameter (fun _ s ->
|
||||||
|
try return (make_sk_uri @@ Uri.of_string s)
|
||||||
|
with Failure s -> failwith "Error while parsing uri: %s" s))
|
||||||
|
params
|
||||||
|
|
||||||
module Secret_key =
|
module Secret_key =
|
||||||
Client_aliases.Alias (Entity(struct let name = "secret_key" end))
|
Client_aliases.Alias (Entity(struct let name = "secret_key" end))
|
||||||
module Public_key =
|
module Public_key =
|
||||||
|
@ -12,6 +12,13 @@
|
|||||||
type pk_uri = private Uri.t
|
type pk_uri = private Uri.t
|
||||||
type sk_uri = private Uri.t
|
type sk_uri = private Uri.t
|
||||||
|
|
||||||
|
val pk_uri_param :
|
||||||
|
?name:string -> ?desc:string ->
|
||||||
|
('a, 'b) Clic.params -> (pk_uri -> 'a, 'b) Clic.params
|
||||||
|
val sk_uri_param :
|
||||||
|
?name:string -> ?desc:string ->
|
||||||
|
('a, 'b) Clic.params -> (sk_uri -> 'a, 'b) Clic.params
|
||||||
|
|
||||||
type error += Unregistered_key_scheme of string
|
type error += Unregistered_key_scheme of string
|
||||||
type error += Invalid_uri of Uri.t
|
type error += Invalid_uri of Uri.t
|
||||||
|
|
||||||
|
@ -166,15 +166,7 @@ let commands () : Client_context.io_wallet Clic.command list =
|
|||||||
(prefix "import"
|
(prefix "import"
|
||||||
@@ prefixes [ "secret" ; "key" ]
|
@@ prefixes [ "secret" ; "key" ]
|
||||||
@@ Secret_key.fresh_alias_param
|
@@ Secret_key.fresh_alias_param
|
||||||
@@ param
|
@@ Client_keys.sk_uri_param
|
||||||
~name:"uri"
|
|
||||||
~desc:"secret key\n\
|
|
||||||
Varies from one scheme to the other.\n\
|
|
||||||
Use command `list signing schemes` for more \
|
|
||||||
information."
|
|
||||||
(parameter (fun _ s ->
|
|
||||||
try return (Client_keys.make_sk_uri @@ Uri.of_string s)
|
|
||||||
with Failure s -> failwith "Error while parsing uri: %s" s))
|
|
||||||
@@ stop)
|
@@ stop)
|
||||||
(fun force name sk_uri (cctxt : Client_context.io_wallet) ->
|
(fun force name sk_uri (cctxt : Client_context.io_wallet) ->
|
||||||
Secret_key.of_fresh cctxt force name >>=? fun name ->
|
Secret_key.of_fresh cctxt force name >>=? fun name ->
|
||||||
@ -196,15 +188,7 @@ let commands () : Client_context.io_wallet Clic.command list =
|
|||||||
(prefix "import"
|
(prefix "import"
|
||||||
@@ prefixes [ "public" ; "key" ]
|
@@ prefixes [ "public" ; "key" ]
|
||||||
@@ Public_key.fresh_alias_param
|
@@ Public_key.fresh_alias_param
|
||||||
@@ param
|
@@ Client_keys.pk_uri_param
|
||||||
~name:"uri"
|
|
||||||
~desc:"public key\n\
|
|
||||||
Varies from one scheme to the other.\n\
|
|
||||||
Use command `list signing schemes` for more \
|
|
||||||
information."
|
|
||||||
(parameter (fun _ s ->
|
|
||||||
try return (Client_keys.make_pk_uri @@ Uri.of_string s)
|
|
||||||
with Failure s -> failwith "Error while parsing uri: %s" s))
|
|
||||||
@@ stop)
|
@@ stop)
|
||||||
(fun force name pk_uri (cctxt : Client_context.io_wallet) ->
|
(fun force name pk_uri (cctxt : Client_context.io_wallet) ->
|
||||||
Public_key.of_fresh cctxt force name >>=? fun name ->
|
Public_key.of_fresh cctxt force name >>=? fun name ->
|
||||||
|
Loading…
Reference in New Issue
Block a user