include module type of Async.CommandAsync.Command is Core.Command with additional Async functions.
include module type of Core.Command with type Command.t = Core.Command.t with module Command.Spec = Core.Command.Specmodule Arg_type : sig ... endmodule Flag : sig ... endmodule Anons : sig ... endmodule Param : sig ... endmodule Let_syntax : sig ... endmodule Spec : sig ... endval basic : ('main, unit) basic_commandval basic' : unit basic_command'val exec : summary:string ‑> ?readme:(unit ‑> string) ‑> path_to_exe:[ `Absolute of string | `Relative_to_me of string ] ‑> unit ‑> tval of_lazy : t Core__.Import.Lazy.t ‑> tval summary : t ‑> stringmodule Shape : sig ... endval run : ?version:string ‑> ?build_info:string ‑> ?argv:string list ‑> ?extend:(string list ‑> string list) ‑> t ‑> unitmodule Deprecated : sig ... endval async : ('a, unit Async_extra.Import.Deferred.t) basic_command with_optionsasync is like Core.Command.basic, except that the main function it expects returns
unit Deferred.t, instead of unit. async will also start the Async scheduler
before main is run, and will stop the scheduler when main returns.
async also handles top-level exceptions by wrapping the user-supplied function in a
Monitor.try_with. If an exception is raised, it will print it to stderr and call
shutdown 1. The extract_exn argument is passed along to Monitor.try_with; by
default it is false.
val async' : unit Async_extra.Import.Deferred.t basic_command' with_optionsval async_basic : ('a, unit Async_extra.Import.Deferred.t) basic_command with_optionsasync_basic is a deprecated synonym for async that will eventually go away. It is
here to give code outside jane street a chance to switch over before we delete it.
val async_or_error : ('a, unit Async_extra.Import.Deferred.Or_error.t) basic_command with_optionsasync_or_error is like async, except that the main function it expects may
return an error, in which case it prints out the error message and shuts down with
exit code 1.
val async_or_error' : unit Async_extra.Import.Deferred.Or_error.t basic_command' with_optionsstaged functions allow the main function to be separated into two stages. The first
part is guaranteed to run before the async scheduler is started, and the second part
will run after the async scheduler is started. This is useful if the main function
runs code that relies on the fact that threads have not been created yet
(e.g. Daemon.daemonize).
As an example:
let main () =
assert (not (Scheduler.is_running ()));
stage (fun `Scheduler_started ->
assert (Scheduler.is_running ());
Deferred.unit
)
module Staged = Async_extra.Command.StagedTo create an Arg_type.t that uses auto-completion and uses Async to compute the
possible completions, one should use
Arg_type.create ~complete of_string
where complete wraps its Async operations in Thread_safe.block_on_async. With
this, the complete function is only called when the executable is auto-completing,
not for ordinary execution. This improves performance, and also means that the Async
scheduler isn't started for ordinary execution of the command, which makes it possible
for the command to daemonize (which requires the scheduler to not have been started).
val rpc : summary:string ‑> ?readme:(unit ‑> string) ‑> ('main, Async.Rpc.Connection.t ‑> unit Async.Deferred.t) Spec.t ‑> 'main ‑> tval config_or_rpc : summary:string ‑> ?readme:(unit ‑> string) ‑> ('main, [ `Config of Async_smtp.Std.Smtp_server.Config.t | `Rpc of Async.Rpc.Connection.t ] ‑> unit Async.Deferred.t) Spec.t ‑> 'main ‑> t