|
18 | 18 | #include "../headers/read_table.h" |
19 | 19 |
|
20 | 20 | static void showErrorMessage(void); |
| 21 | +static void showUserHelp(void); |
21 | 22 | static void explodeCondition(StringArray *conditions, char *string, char *position, char *delimiter); |
22 | 23 |
|
23 | 24 | // |
@@ -72,6 +73,11 @@ void parseEntry(Manager manager, char *currentDatabase, char *entry) |
72 | 73 | strcat(entryPart, charToString); |
73 | 74 | } |
74 | 75 |
|
| 76 | + if (strcmp(entryArray->data[0], "HELP") == 0) { |
| 77 | + showUserHelp(); |
| 78 | + return; |
| 79 | + } |
| 80 | + |
75 | 81 | if (entryArray->size < 2) { |
76 | 82 | showErrorMessage(); |
77 | 83 | return; |
@@ -422,3 +428,35 @@ void explodeCondition(StringArray *conditions, char *string, char *position, cha |
422 | 428 | appendToStringArray(conditions, value); |
423 | 429 | } |
424 | 430 |
|
| 431 | +void showUserHelp() |
| 432 | +{ |
| 433 | + printf("\nWelcome to the user manual!\n"); |
| 434 | + printf("\n"); |
| 435 | + printf("----------------------------\n"); |
| 436 | + printf(" - - \n"); |
| 437 | + printf(" - USER MANUAL - \n"); |
| 438 | + printf(" - - \n"); |
| 439 | + printf("----------------------------\n"); |
| 440 | + printf("\nWrite your query after : \"yaml_db >\"\n"); |
| 441 | + printf("\nKeywords from SQL must be written in capital\n"); |
| 442 | + printf("Query must end with \";\"\n"); |
| 443 | + printf("\nUsers can write values with quotes, only if the values is a string\n"); |
| 444 | + printf("Users cans use simple or double quote.\n"); |
| 445 | + printf("\n\"INSERT INTO\" query works with explicit and implicit column name.\n"); |
| 446 | + printf("With explicit name, users just have to specify some colmun name\n"); |
| 447 | + printf("With implicit users must set value to every column\n"); |
| 448 | + printf("\nTo read datas, users can select all columns, a specific column.\n"); |
| 449 | + printf("Users can use where condition.\n"); |
| 450 | + printf("Where coniditon works with \"LIKE\" or with \"=\".\n"); |
| 451 | + printf("\nHere is some query exemples users can use :\n\n"); |
| 452 | + printf("SHOW DATABASES;\n"); |
| 453 | + printf("USE db_name;\n"); |
| 454 | + printf("CREATE TABLE table_name (col1 type, col2 type, ...);\n"); |
| 455 | + printf("INSERT INTO table_name (col1, col2) VALUES (val1, val2);\n"); |
| 456 | + printf("INSERT INTO table_name (val1, val2);\n"); |
| 457 | + printf("UPDATE table_name SET col1 = val1, col2 = val2 WHERE id = 1 OR name = quentin;\n"); |
| 458 | + printf("DELETE FROM table_name WHERE id = 1 AND name != quentin OR age = 22;\n"); |
| 459 | + printf("DROP TABLE table_name;\nDROP DATABASE db_name;\n"); |
| 460 | + printf("EXIT; QUIT;\n"); |
| 461 | + return; |
| 462 | +} |
0 commit comments