Module Async_smtp_command.Common.Command

include module type of Async.Command

Async.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.Spec
module Arg_type : sig ... end
module Flag : sig ... end
module Anons : sig ... end
module Param : sig ... end
module Let_syntax : sig ... end
module Spec : sig ... end
type ('main, 'result) basic_command = summary:string ‑> ?readme:(unit ‑> string) ‑> ('main, unit ‑> 'resultSpec.t ‑> 'main ‑> t
val basic : ('main, unit) basic_command
type 'result basic_command' = summary:string ‑> ?readme:(unit ‑> string) ‑> (unit ‑> 'result) Param.t ‑> t
val basic' : unit basic_command'
val group : summary:string ‑> ?readme:(unit ‑> string) ‑> ?preserve_subcommand_order:unit ‑> ?body:(path:string list ‑> unit) ‑> (string * t) list ‑> t
val exec : summary:string ‑> ?readme:(unit ‑> string) ‑> path_to_exe:[ `Absolute of string | `Relative_to_me of string ] ‑> unit ‑> t
val of_lazy : t Core__.Import.Lazy.t ‑> t
val summary : t ‑> string
module Shape : sig ... end
val shape : t ‑> Shape.t
val run : ?version:string ‑> ?build_info:string ‑> ?argv:string list ‑> ?extend:(string list ‑> string list) ‑> t ‑> unit
module Deprecated : sig ... end
type 'a with_options = ?extract_exn:bool ‑> 'a

async 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.

async_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.

async_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.

staged 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
        )
    
type 'r staged = ([ `Scheduler_started ] ‑> 'r) Core.Staged.t

To 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) ‑> ('mainAsync.Rpc.Connection.t ‑> unit Async.Deferred.tSpec.t ‑> 'main ‑> t
val 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.tSpec.t ‑> 'main ‑> t