2016-09-08 21:13:10 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Copyright (c) 2014 - 2016. *)
|
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
(* Tezos: a small Command Line Parsing library *)
|
|
|
|
(* Only used in the client. *)
|
|
|
|
|
|
|
|
exception Command_not_found
|
|
|
|
exception Bad_argument of int * string * string
|
|
|
|
exception Command_failed of string
|
|
|
|
|
2016-12-03 16:05:02 +04:00
|
|
|
type ('a, 'arg, 'ret) params
|
|
|
|
type ('arg, 'ret) command
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
val param:
|
|
|
|
name: string ->
|
|
|
|
desc: string ->
|
2016-12-03 16:05:02 +04:00
|
|
|
('arg -> string -> 'a Lwt.t) ->
|
|
|
|
('b, 'arg, 'ret) params ->
|
|
|
|
('a -> 'b, 'arg, 'ret) params
|
|
|
|
val prefix:
|
|
|
|
string ->
|
|
|
|
('a, 'arg, 'ret) params ->
|
|
|
|
('a, 'arg, 'ret) params
|
|
|
|
val prefixes:
|
|
|
|
string list ->
|
|
|
|
('a, 'arg, 'ret) params ->
|
|
|
|
('a, 'arg, 'ret) params
|
|
|
|
val fixed:
|
|
|
|
string list ->
|
|
|
|
('arg -> 'ret Lwt.t, 'arg, 'ret) params
|
|
|
|
val stop:
|
|
|
|
('arg -> 'ret Lwt.t, 'arg, 'ret) params
|
2016-09-08 21:13:10 +04:00
|
|
|
val seq:
|
|
|
|
name: string ->
|
|
|
|
desc: string ->
|
2016-12-03 16:05:02 +04:00
|
|
|
('arg -> string -> 'p Lwt.t) ->
|
|
|
|
('p list -> 'arg -> 'ret Lwt.t, 'arg, 'ret) params
|
|
|
|
|
|
|
|
val string:
|
|
|
|
name: string ->
|
|
|
|
desc: string ->
|
|
|
|
('a, 'arg, 'ret) params ->
|
|
|
|
(string -> 'a, 'arg, 'ret) params
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
val seq_of_param:
|
2016-12-03 16:05:02 +04:00
|
|
|
(('arg -> 'ret Lwt.t, 'arg, 'ret) params ->
|
|
|
|
('a -> 'arg -> 'ret Lwt.t, 'arg, 'ret) params) ->
|
|
|
|
('a list -> 'arg -> 'ret Lwt.t, 'arg, 'ret) params
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2016-12-03 16:05:02 +04:00
|
|
|
type group =
|
|
|
|
{ name : string ;
|
|
|
|
title : string }
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2016-12-03 16:05:02 +04:00
|
|
|
val command:
|
|
|
|
?group: group ->
|
|
|
|
?args: (Arg.key * Arg.spec * Arg.doc) list ->
|
|
|
|
desc: string ->
|
|
|
|
('a, 'arg, 'ret) params -> 'a -> ('arg, 'ret) command
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
val usage:
|
2016-12-03 16:05:02 +04:00
|
|
|
commands: ('arg, 'ret) command list ->
|
|
|
|
(string * Arg.spec * string) list -> string
|
|
|
|
|
2016-11-22 17:23:40 +04:00
|
|
|
val inline_dispatch:
|
2016-12-03 16:05:02 +04:00
|
|
|
('arg, 'ret) command list -> unit ->
|
2016-12-02 02:20:23 +04:00
|
|
|
[ `Arg of string | `End ] ->
|
|
|
|
[ `Args of (Arg.key * Arg.spec * Arg.doc) list
|
2016-09-08 21:13:10 +04:00
|
|
|
| `Fail of exn
|
|
|
|
| `Nop
|
2016-12-03 16:05:02 +04:00
|
|
|
| `Res of 'arg -> 'ret Lwt.t ]
|
2016-11-22 17:23:40 +04:00
|
|
|
|
|
|
|
val dispatch:
|
2016-12-03 16:05:02 +04:00
|
|
|
('arg, 'ret) command list -> 'arg -> string list -> 'ret Lwt.t
|