Async.Command
is Core.Command
with additional Async functions.
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_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.
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).