package async_smtp
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=c416027c2537e22129f7049bf03ec3f867557d47b194d7e91d72c399fe656b27
doc/async_smtp.command/Async_smtp_command/Common/Command/index.html
Module Common.CommandSource
include module type of Async.Command
include module type of struct include Async_command end
include module type of struct include Core.Command end
include module type of struct include Command end
module type Enumerable_sexpable = Async_command.Enumerable_sexpablemodule type Enumerable_stringable = Async_command.Enumerable_stringablemodule Auto_complete = Async_command.Auto_completeSpecifications for command-line auto-completion.
module Flag = Async_command.FlagCommand-line flag specifications.
module Anons = Async_command.AnonsAnonymous command-line argument specification.
type t = Command.tCommands which can be combined into a hierarchy of subcommands.
type ('main, 'result) basic_spec_command =
summary:Base.string ->
?readme:(Base.unit -> Base.string) ->
('main, Base.unit -> 'result) Command.Spec.t ->
'main ->
tval basic_spec : ('main, Base.unit) basic_spec_commandbasic_spec ~summary ?readme spec main is a basic command that executes a function main which is passed parameters parsed from the command line according to spec. summary is to contain a short one-line description of its behavior. readme is to contain any longer description of its behavior that will go on that command's help screen.
type 'result basic_command =
summary:Base.string ->
?readme:(Base.unit -> Base.string) ->
(Base.unit -> 'result) Command.Param.t ->
tval basic : Base.unit basic_commandSame general behavior as basic_spec, but takes a command line specification built up using Params instead of Spec.
val basic_or_error : Base.unit Base.Or_error.t basic_commandbasic_or_error is like basic, 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 group :
summary:Base.string ->
?readme:(Base.unit -> Base.string) ->
?preserve_subcommand_order:Base.unit ->
?body:(path:Base.string Base.list -> Base.unit) ->
(Base.string * t) Base.list ->
tgroup ~summary subcommand_alist is a compound command with named subcommands, as found in subcommand_alist. summary is to contain a short one-line description of the command group. readme is to contain any longer description of its behavior that will go on that command's help screen.
NOTE: subcommand names containing underscores will be rejected; use dashes instead.
body is called when no additional arguments are passed -- in particular, when no subcommand is passed. Its path argument is the subcommand path by which the group command was reached.
val lazy_group :
summary:Base.string ->
?readme:(Base.unit -> Base.string) ->
?preserve_subcommand_order:Base.unit ->
?body:(path:Base.string Base.list -> Base.unit) ->
(Base.string * t) Base.list Base.Lazy.t ->
tlazy_group is the same as group, except that the list of subcommands may be generated lazily.
val exec :
summary:Base.string ->
?readme:(Base.unit -> Base.string) ->
?child_subcommand:Base.string Base.list ->
?env:Command__.Command_intf.env ->
path_to_exe:
[ `Absolute of Base.string
| `Relative_to_argv0 of Base.string
| `Relative_to_me of Base.string ] ->
Base.unit ->
texec ~summary ~path_to_exe runs exec on the executable at path_to_exe. If path_to_exe is `Absolute path then path is executed without any further qualification. If it is `Relative_to_me path then Filename.dirname Sys.executable_name ^ "/" ^ path is executed instead. All of the usual caveats about Sys.executable_name apply: specifically, it may only return an absolute path in Linux. On other operating systems it will return Sys.argv.(0). If it is `Relative_to_argv0 path then Sys.argv.(0) ^ "/" ^ path is executed.
The child_subcommand argument allows referencing a subcommand one or more levels below the top-level of the child executable. It should not be used to pass flags or anonymous arguments to the child.
Care has been taken to support nesting multiple executables built with Command. In particular, recursive help and autocompletion should work as expected.
NOTE: Non-Command executables can be used with this function but will still be executed when help -recursive is called or autocompletion is attempted (despite the fact that neither will be particularly helpful in this case). This means that if you have a shell script called "reboot-everything.sh" that takes no arguments and reboots everything no matter how it is called, you shouldn't use it with exec.
Additionally, no loop detection is attempted, so if you nest an executable within itself, help -recursive and autocompletion will hang forever (although actually running the subcommand will work).
val of_lazy : t Base.Lazy.t -> tof_lazy thunk constructs a lazy command that is forced only when necessary to run it or extract its shape.
val summary : t -> Base.stringExtracts the summary string for a command.
module Shape = Async_command.Shapeval exit : Base.int -> _call this instead of Core.exit if in command-related code that you want to run in tests. For example, in the body of Command.Param.no_arg_abort
module For_telemetry = Async_command.For_telemetrymodule Deprecated = Async_command.DeprecatedDeprecated should be used only by Deprecated_command. At some point it will go away.
Deprecated values that moved from Core.Command to Command_unix.
module Path = Async_command.Pathmodule Arg_type = Async_command.Arg_typemodule Param = Async_command.Parammodule Spec = Async_command.Specmodule Let_syntax = Async_command.Let_syntaxval async : unit Async_kernel.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.
If behave_nicely_in_pipeline is true, then Writer.behave_nicely_in_pipeline () is called when the command starts. Its default is true.
val async_spec :
('a, unit Async_kernel.Deferred.t) basic_spec_command with_optionsval async_or_error :
unit Async_kernel.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_spec_or_error :
('a, unit Async_kernel.Deferred.Or_error.t) basic_spec_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 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.tmodule Staged = Async_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_stringwhere 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).
module For_testing = Async_command.For_testingval rpc :
summary:string ->
?readme:(unit -> string) ->
(Async.Rpc.Connection.t -> unit Async.Deferred.t) Param.t ->
tval configs_or_rpc :
summary:string ->
?readme:(unit -> string) ->
([ `Configs of
Async_smtp.Smtp_server.Config.t * Async_smtp.Smtp_spool.Config.t
| `Rpc of Async.Rpc.Connection.t ] ->
unit Async.Deferred.t)
Param.t ->
t