struct command *parent;
struct command *children;
command_handler_t handler;
+ Jim_CmdProc jim_handler;
+ void *jim_handler_data;
enum command_mode mode;
struct command *next;
};
struct command_registration {
const char *name;
command_handler_t handler;
+ Jim_CmdProc jim_handler;
+ void *jim_handler_data;
enum command_mode mode;
const char *help;
/// a string listing the options and arguments, required or optional
const char *usage;
+
+ /**
+ * If non-NULL, the commands in @c chain will be registered in
+ * the same context and scope of this registration record.
+ * This allows modules to inherit lists commands from other
+ * modules.
+ */
+ const struct command_registration *chain;
};
/// Use this as the last entry in an array of command_registration records.
-#define COMMAND_REGISTRATION_DONE { .name = NULL }
+#define COMMAND_REGISTRATION_DONE { .name = NULL, .chain = NULL }
/**
* Register a command @c handler that can be called from scripts during
/**
* Register one or more commands in the specified context, as children
- * of @c parent (or top-level commends, if NULL).
+ * of @c parent (or top-level commends, if NULL). In a registration's
+ * record contains a non-NULL @c chain member and name is NULL, the
+ * commands on the chain will be registered in the same context.
+ * Otherwise, the chained commands are added as children of the command.
*
* @param cmd_ctx The command_context in which to register the command.
* @param parent Register this command as a child of this, or NULL to
int unregister_all_commands(struct command_context *cmd_ctx,
struct command *parent);
+struct command *command_find_in_context(struct command_context *cmd_ctx,
+ const char *name);
+struct command *command_find_in_parent(struct command *parent,
+ const char *name);
+
void command_set_output_handler(struct command_context* context,
command_output_handler_t output_handler, void *priv);
extern Jim_Interp *interp;
-void register_jim(struct command_context *context, const char *name,
- Jim_CmdProc cmd, const char *help);
-
int parse_ulong(const char *str, unsigned long *ul);
int parse_ullong(const char *str, unsigned long long *ul);