Skip to content

Commit 5cd1fb6

Browse files
committed
cleanup: Indicate when a python command has successfully registered
The /run command can both run and register scripts. We now indicate when a command has been successfully registered.
1 parent 1a97b2b commit 5cd1fb6

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/python_api.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,12 @@ static PyObject *python_api_register(PyObject *self, PyObject *args)
160160
PyObject *callback;
161161

162162
if (!PyArg_ParseTuple(args, "ssO:register_command", &command, &help, &callback)) {
163+
PyErr_SetString(PyExc_TypeError, "Failed to parse PyArg tuple");
163164
return NULL;
164165
}
165166

166167
if (!PyCallable_Check(callback)) {
167-
PyErr_SetString(PyExc_TypeError, "Calback parameter must be callable");
168+
PyErr_SetString(PyExc_TypeError, "Callback parameter must be callable");
168169
return NULL;
169170
}
170171

@@ -207,6 +208,19 @@ static PyObject *python_api_register(PyObject *self, PyObject *args)
207208
strncpy(cur->next->help, help, help_len + 1);
208209
cur->next->callback = callback;
209210
cur->next->next = NULL;
211+
212+
const size_t msg_len = command_len + 64;
213+
char *msg = malloc(msg_len);
214+
215+
if (msg == NULL) {
216+
break;
217+
}
218+
219+
snprintf(msg, msg_len, "Registered command: \"%s\"", command);
220+
api_display(msg);
221+
222+
free(msg);
223+
210224
break;
211225
}
212226
}

0 commit comments

Comments
 (0)