1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-26 22:53:28 +01:00

Add documentation/error messages for missing quotation marks

This commit is contained in:
Luke Champine 2013-09-02 17:48:16 -04:00
parent a0e3b7dfd1
commit 82dee36729

View File

@ -92,8 +92,8 @@ void cmd_accept(ToxWindow *self, Tox *m, int argc, char **argv)
num = atoi(argv[1]); num = atoi(argv[1]);
if (num >= num_requests) { if (num < 0 || num >= num_requests) {
wprintw(self->window, "Invalid syntax.\n"); wprintw(self->window, "No pending request with that number.\n");
return; return;
} }
@ -117,6 +117,10 @@ void cmd_add(ToxWindow *self, Tox *m, int argc, char **argv)
int i, num; int i, num;
/* check arguments */ /* check arguments */
if (argv[2] && argv[2][0] != '\"') {
wprintw(self->window, "Strings must be enclosed in quotes.\n");
return;
}
if (argc != 1 && argc != 2) { if (argc != 1 && argc != 2) {
wprintw(self->window, "Invalid syntax.\n"); wprintw(self->window, "Invalid syntax.\n");
return; return;
@ -249,6 +253,7 @@ void cmd_help(ToxWindow *self, Tox *m, int argc, char **argv)
wprintw(self->window, " clear : Clear this window\n"); wprintw(self->window, " clear : Clear this window\n");
wattron(self->window, A_BOLD); wattron(self->window, A_BOLD);
wprintw(self->window, "NOTE: Strings must be enclosed in quotation marks.\n");
wprintw(self->window, "TIP: Use the TAB key to navigate through the tabs.\n\n"); wprintw(self->window, "TIP: Use the TAB key to navigate through the tabs.\n\n");
wattroff(self->window, A_BOLD); wattroff(self->window, A_BOLD);
@ -323,8 +328,12 @@ void cmd_status(ToxWindow *self, Tox *m, int argc, char **argv)
char *status, *status_text, *msg; char *status, *status_text, *msg;
/* check arguments */ /* check arguments */
if (argv[2] && argv[2][0] != '\"') {
wprintw(self->window, "Strings must be enclosed in quotes.\n");
return;
}
if (argc != 1 && argc != 2) { if (argc != 1 && argc != 2) {
wprintw(self->window, "Invalid syntax.\n"); wprintw(self->window, "Wrong number of arguments.\n");
return; return;
} }
@ -363,8 +372,12 @@ void cmd_statusmsg(ToxWindow *self, Tox *m, int argc, char **argv)
char *msg; char *msg;
/* check arguments */ /* check arguments */
if (argv[1] && argv[1][0] != '\"') {
wprintw(self->window, "Strings must be enclosed in quotes.\n");
return;
}
if (argc != 1) { if (argc != 1) {
wprintw(self->window, "Invalid syntax.\n"); wprintw(self->window, "Wrong number of arguments.\n");
return; return;
} }
@ -412,7 +425,7 @@ static void execute(ToxWindow *self, Tox *m, char *u_cmd)
/* skip over strings */ /* skip over strings */
else if (cmd[i] == '\"') { else if (cmd[i] == '\"') {
while (cmd[++i] != '\"') { while (cmd[++i] != '\"') {
if (cmd[i] == '\n') { if (cmd[i] == '\0') {
wprintw(self->window, "Invalid command: did you forget a closing \"?\n"); wprintw(self->window, "Invalid command: did you forget a closing \"?\n");
return; return;
} }