|
Blender V4.3
|
#include <Python.h>#include "BLI_utildefines.h"#include "bpy_capi_utils.hh"#include "MEM_guardedalloc.h"#include "BKE_blender_cli_command.hh"#include "../generic/py_capi_utils.hh"#include "../generic/python_compat.hh"#include "../generic/python_utildefines.hh"#include "bpy_cli_command.hh"Go to the source code of this file.
Classes | |
| class | BPyCommandHandler |
Functions | |
Internal Utilities | |
| static PyObject * | py_argv_from_bytes (const int argc, const char **argv) |
Internal Implementation | |
| static int | bpy_cli_command_exec (bContext *C, PyObject *py_exec_fn, const int argc, const char **argv) |
| static void | bpy_cli_command_free (PyObject *py_exec_fn) |
Variables | |
| static const char * | bpy_cli_command_capsule_name = "bpy_cli_command" |
| static const char * | bpy_cli_command_capsule_name_invalid = "bpy_cli_command<invalid>" |
Public Methods | |
| PyMethodDef | BPY_cli_command_register_def |
| PyMethodDef | BPY_cli_command_unregister_def |
| PyDoc_STRVAR (bpy_cli_command_register_doc, ".. method:: register_cli_command(id, execute)\n" "\n" " Register a command, accessible via the (``-c`` / ``--command``) command-line argument.\n" "\n" " :arg id: The command identifier (must pass an ``str.isidentifier`` check).\n" "\n" " If the ``id`` is already registered, a warning is printed and " "the command is inaccessible to prevent accidents invoking the wrong command.\n" " :type id: str\n" " :arg execute: Callback, taking a single list of strings and returns an int.\n" " The arguments are built from all command-line arguments following the command id.\n" " The return value should be 0 for success, 1 on failure " "(specific error codes from the ``os`` module can also be used).\n" " :type execute: callable\n" " :return: The command handle which can be passed to :func:`unregister_cli_command`.\n" " :rtype: capsule\n") | |
| static PyObject * | bpy_cli_command_register (PyObject *, PyObject *args, PyObject *kw) |
| PyDoc_STRVAR (bpy_cli_command_unregister_doc, ".. method:: unregister_cli_command(handle)\n" "\n" " Unregister a CLI command.\n" "\n" " :arg handle: The return value of :func:`register_cli_command`.\n" " :type handle: capsule\n") | |
| static PyObject * | bpy_cli_command_unregister (PyObject *, PyObject *value) |
Wrap BKE_command_cli_* to support custom CLI commands.
Definition in file bpy_cli_command.cc.
|
static |
Definition at line 63 of file bpy_cli_command.cc.
References bpy_context_clear(), bpy_context_set(), and py_argv_from_bytes().
Referenced by BPyCommandHandler::exec().
|
static |
Definition at line 147 of file bpy_cli_command.cc.
Referenced by BPyCommandHandler::~BPyCommandHandler().
|
static |
Definition at line 207 of file bpy_cli_command.cc.
References BKE_blender_cli_command_register(), bpy_cli_command_capsule_name, and PY_ARG_PARSER_HEAD_COMPAT.
|
static |
Definition at line 258 of file bpy_cli_command.cc.
References BKE_blender_cli_command_unregister(), bpy_cli_command_capsule_name, bpy_cli_command_capsule_name_invalid, and BPyCommandHandler::py_exec_fn.
|
static |
Return a list of strings, compatible with the construction of Python's sys.argv.
Definition at line 36 of file bpy_cli_command.cc.
References BLI_assert, and UNLIKELY.
Referenced by bpy_cli_command_exec().
| PyDoc_STRVAR | ( | bpy_cli_command_register_doc | , |
| ".. method:: register_cli_command(id, execute)\n" "\n" " Register a | command, | ||
| accessible via the(``-c``/``--command``) command-line argument.\n" "\n" " :arg id:The command identifier(must pass an ``str.isidentifier`` check).\n" "\n" " If the ``id`` is already | registered, | ||
| a warning is printed and " "the command is inaccessible to prevent accidents invoking the wrong command.\n" " :type id:str\n" " :arg execute:Callback | , | ||
| taking a single list of strings and returns an int.\n" " The arguments are built from all command-line arguments following the command id.\n" " The return value should be 0 for | success, | ||
| 1 on failure " "(specific error codes from the ``os`` module can also be used).\n" " :type execute:callable\n" " :return:The command handle which can be passed to :func:`unregister_cli_command`.\n" " :rtype:capsule\n" | ) |
| PyDoc_STRVAR | ( | bpy_cli_command_unregister_doc | , |
| ".. method:: unregister_cli_command(handle)\n" "\n" " Unregister a CLI command.\n" "\n" " :arg handle: The return value of :func:`register_cli_command`.\n" " :type handle: capsule\n" | ) |
|
static |
Definition at line 26 of file bpy_cli_command.cc.
Referenced by bpy_cli_command_register(), and bpy_cli_command_unregister().
|
static |
Definition at line 27 of file bpy_cli_command.cc.
Referenced by bpy_cli_command_unregister().
| PyMethodDef BPY_cli_command_register_def |
Definition at line 298 of file bpy_cli_command.cc.
Referenced by BPy_init_modules().
| PyMethodDef BPY_cli_command_unregister_def |
Definition at line 304 of file bpy_cli_command.cc.
Referenced by BPy_init_modules().