Skip to content

Commit c96f8c1

Browse files
PironPqboot
authored andcommitted
Ajout de la commande HELP;
1 parent 4d07b08 commit c96f8c1

File tree

5 files changed

+39
-6
lines changed

5 files changed

+39
-6
lines changed

sources/headers/manage_file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ char* createFileInDir(const char *filename, const char *dirname);
1818
void removeFile(const char *filename);
1919
void removeFileInDir(const char *filename, const char *dirname);
2020
int isFile(const char *filename);
21-
void createRootDir();
21+
void createRootDir(void);
2222
void createDir(const char *dirname);
2323
void removeDir(const char *dirname);
2424
int isValidName(const char *name);

sources/sources/manage_entry.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "../headers/read_table.h"
1919

2020
static void showErrorMessage(void);
21+
static void showUserHelp(void);
2122
static void explodeCondition(StringArray *conditions, char *string, char *position, char *delimiter);
2223

2324
//
@@ -72,6 +73,11 @@ void parseEntry(Manager manager, char *currentDatabase, char *entry)
7273
strcat(entryPart, charToString);
7374
}
7475

76+
if (strcmp(entryArray->data[0], "HELP") == 0) {
77+
showUserHelp();
78+
return;
79+
}
80+
7581
if (entryArray->size < 2) {
7682
showErrorMessage();
7783
return;
@@ -422,3 +428,35 @@ void explodeCondition(StringArray *conditions, char *string, char *position, cha
422428
appendToStringArray(conditions, value);
423429
}
424430

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+
}

sources/sources/manage_file.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,6 @@ void removeFileInDir(const char *filename, const char *dirname)
154154
//
155155
int isFile(const char *filename)
156156
{
157-
printf("%s", filename);
158-
159157
FILE *file = fopen(filename, "r");
160158

161159
if (file != NULL) {

yaml_db.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757
66A181901FDD70DB002C675F /* manage_parsing.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = manage_parsing.h; sourceTree = "<group>"; };
5858
66A181911FDD70E4002C675F /* manage_parsing.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = manage_parsing.c; sourceTree = "<group>"; };
5959
66A181921FDD70E4002C675F /* manage_entry.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = manage_entry.c; sourceTree = "<group>"; };
60-
E80F362B1FDD858F0030660A /* manage_array.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = manage_array.h; sourceTree = "<group>"; };
61-
E80F362C1FDD858F0030660A /* manage_array.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = manage_array.c; sourceTree = "<group>"; };
6260
E80F362E1FDD89A10030660A /* read_file.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = read_file.h; sourceTree = "<group>"; };
6361
E80F362F1FDD89A10030660A /* read_file.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = read_file.c; sourceTree = "<group>"; };
6462
E83BFB7F1FC9E6B400A5B18D /* read_table.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = read_table.h; sourceTree = "<group>"; };

yaml_db/databases/databases.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)