workflow#

Alfred Workflow module.

afwf.workflow.log_last_error()[source]#

Log the last exception trace back info to ~/.alfred-afwf/last-error.txt file.

afwf.workflow.log_debug_info(info: str)[source]#

Call this function anywhere. It will append the info string to the end of ~/.alfred-afwf/debug.txt file.

class afwf.workflow.Workflow(handlers: Dict[str, Handler] = _Nothing.NOTHING)[source]#

Represents an Alfred Workflow object. The workflow can register many handlers.

Each handler will be responsible for a Script Filter implementation.

[CN]

表示一个 Alfred Workflow 对象. 一个 workflow 可以注册多个 handler. 每个 handler 对应着一个 Script Filter 的实现.

register(handler: Handler)[source]#

Register a handler to the workflow.

get(handler_id: str) Handler[source]#

Get handler by id.

run(arg: Optional[str] = None, debug: bool = False)[source]#

High level script filter runner.

Parameters:

debug – flag to turn on debug.

By default, it provides two ways to debug:

  1. Automatically log the sys.argv, handler id and query string history to

    ~/.alfred-afwf/debug.txt file.

  2. If python raises any exception, log the Exception trace back message

    to ~/.alfred-afwf/last-error.txt. And show two item to allow user to open the ``debug.txt or last-error.txt file.