onetime_only: Wrap a function to be called only once
Description
This takes a function and returns the same function wrapped by onetime_do().
Use it for code which should run only once, but which may be called from
multiple locations. This frees you from having to use the same id multiple
times.
A wrapped function. The function itself returns the result of .f,
or default if the inner function was not called.
Arguments
.f
A function
id
Unique ID string. If this is unset, the name of the calling
package will be used. Since onetime 0.2.0, not setting id is
deprecated.
path
Directory to store lockfiles. The default uses a unique
directory corresponding to the calling package, beneath
rappdirs::user_config_dir(). Normally you should leave this as the
default.
default
Value to return from .f if function was not executed.
without_permission
Character string. What to do if the user hasn't
given permission to store files? "warn" runs the action with an extra
warning; "run" runs the action with no warning; "pass" does nothing
and returns the default; "stop" throws an error; "ask" asks for
permission using check_ok_to_store(), and returns the default if it is
not granted.