Initial commit

This commit is contained in:
Nanokloon 2025-04-01 20:41:06 +02:00
parent 23a31f53cb
commit b6ae0e3b65
7 changed files with 56 additions and 11 deletions

View File

@ -5,4 +5,9 @@ set(CMAKE_C_STANDARD 23)
add_executable(breeze main.c
func.c
func.h)
func.h
config/import.c
config/export.c
config/config.c
config/config.h
)

3
config.json Normal file
View File

@ -0,0 +1,3 @@
{
"test": "test"
}

3
config/config.c Normal file
View File

@ -0,0 +1,3 @@
//
// Created by nano on 4/1/25.
//

8
config/config.h Normal file
View File

@ -0,0 +1,8 @@
//
// Created by nano on 4/1/25.
//
#ifndef CONFIG_H
#define CONFIG_H
void loadConfig(char *filepath);
#endif //CONFIG_H

3
config/export.c Normal file
View File

@ -0,0 +1,3 @@
//
// Created by nano on 4/1/25.
//

17
config/import.c Normal file
View File

@ -0,0 +1,17 @@
//
// Created by nano on 4/1/25.
//
#include <limits.h>
#include <stdio.h>
void loadConfig(char *filepath) {
FILE *fp;
fp = fopen(filepath, "r");
char configFile[1024];
while (fgets(configFile, 1024, fp)) {
printf("%s", configFile);
}
fclose(fp);
}

26
main.c
View File

@ -1,7 +1,7 @@
#include <stdio.h>
#include <string.h>
#include "func.h"
#include "config/config.h"
char *defaultOptions[]={"help","add","run","del","rm"};
@ -10,33 +10,39 @@ void delCmd(char ** str);
void runCmd(char ** str);
int main(int argc, char *argv[]) {
//printf("%d \n", argc);
if (argc<2) {
printHelp();
return 0;
}
int choice = whichOption(defaultOptions,argv[1]);
printf(argv[1]);
printf("choice is %d \n",choice);
switch (choice) {
case 0:
printHelp();
return 0;
case 1: // add
addCmd(&argv[2]);
return 0;
case 2: // run
runCmd(&argv[2]);
return 0;
case 3:
case 4:
delCmd(argv[2]);
default:
printf("not yet implemented\\invalid");
case 4: {
delCmd(&argv[2]);
return 0;
}
default: ;
}
loadConfig("config.json");
return 0;
}
void addCmd(char ** str) { //TODO: implement
printf("adding %s \n", *str);
int i=0;
while (*(str+i)) {
printf("adding %s \n", *(str+i));
i++;
}
}
void delCmd(char ** str) { //TODO: implement
printf("removed %s \n", *str);