Blender V5.3
blender_cli_command.cc File Reference
#include <iostream>
#include "BLI_vector.hh"
#include "BKE_blender_cli_command.hh"

Go to the source code of this file.

Namespaces

namespace  blender
 BMesh Iterators.

Functions

Public API
void blender::BKE_blender_cli_command_register (std::unique_ptr< CommandHandler > cmd)
bool blender::BKE_blender_cli_command_unregister (CommandHandler *cmd)
int blender::BKE_blender_cli_command_exec (struct bContext *C, const char *id, const int argc, const char **argv)
void blender::BKE_blender_cli_command_print_help ()
void blender::BKE_blender_cli_command_free_all ()

Internal API

Note
While we could have a separate type for ID's, use RNA since there is enough overlap.
using blender::CommandHandlerPtr = std::unique_ptr<CommandHandler>
static Vector< CommandHandlerPtr > & blender::cli_command_handlers ()
static CommandHandler * blender::blender_cli_command_lookup (const std::string &id)
static int blender::blender_cli_command_index (const CommandHandler *cmd)

Detailed Description

Generic CLI "--command" declarations.

Duplicate Commands

When two or more commands share the same identifier, a warning is printed and both are disabled.

This is done because command-line actions may be destructive so the down-side of running the wrong command could be severe. The reason this is not considered an error is we can't prevent it so easily, unlike operator ID's which may be longer, commands are typically short terms which wont necessarily include an add-ons identifier as a prefix for example. Further, an error would break loading add-ons who's primary is not necessarily to provide command-line access. An alternative solution could be to generate unique names (number them for example) but this isn't reliable as it would depend on it the order add-ons are loaded which isn't under user control.

Definition in file blender_cli_command.cc.