Initial commit
This commit is contained in:
parent
23a31f53cb
commit
b6ae0e3b65
@ -5,4 +5,9 @@ set(CMAKE_C_STANDARD 23)
|
|||||||
|
|
||||||
add_executable(breeze main.c
|
add_executable(breeze main.c
|
||||||
func.c
|
func.c
|
||||||
func.h)
|
func.h
|
||||||
|
config/import.c
|
||||||
|
config/export.c
|
||||||
|
config/config.c
|
||||||
|
config/config.h
|
||||||
|
)
|
||||||
|
|||||||
3
config.json
Normal file
3
config.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"test": "test"
|
||||||
|
}
|
||||||
3
config/config.c
Normal file
3
config/config.c
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
//
|
||||||
|
// Created by nano on 4/1/25.
|
||||||
|
//
|
||||||
8
config/config.h
Normal file
8
config/config.h
Normal 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
3
config/export.c
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
//
|
||||||
|
// Created by nano on 4/1/25.
|
||||||
|
//
|
||||||
17
config/import.c
Normal file
17
config/import.c
Normal 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
26
main.c
@ -1,7 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "func.h"
|
#include "func.h"
|
||||||
|
#include "config/config.h"
|
||||||
|
|
||||||
char *defaultOptions[]={"help","add","run","del","rm"};
|
char *defaultOptions[]={"help","add","run","del","rm"};
|
||||||
|
|
||||||
@ -10,33 +10,39 @@ void delCmd(char ** str);
|
|||||||
void runCmd(char ** str);
|
void runCmd(char ** str);
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
//printf("%d \n", argc);
|
|
||||||
if (argc<2) {
|
if (argc<2) {
|
||||||
printHelp();
|
printHelp();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int choice = whichOption(defaultOptions,argv[1]);
|
int choice = whichOption(defaultOptions,argv[1]);
|
||||||
printf(argv[1]);
|
|
||||||
printf("choice is %d \n",choice);
|
|
||||||
|
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
|
case 0:
|
||||||
|
printHelp();
|
||||||
|
return 0;
|
||||||
case 1: // add
|
case 1: // add
|
||||||
addCmd(&argv[2]);
|
addCmd(&argv[2]);
|
||||||
|
return 0;
|
||||||
case 2: // run
|
case 2: // run
|
||||||
runCmd(&argv[2]);
|
runCmd(&argv[2]);
|
||||||
|
return 0;
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4: {
|
||||||
delCmd(argv[2]);
|
delCmd(&argv[2]);
|
||||||
default:
|
|
||||||
printf("not yet implemented\\invalid");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
default: ;
|
||||||
|
}
|
||||||
|
loadConfig("config.json");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addCmd(char ** str) { //TODO: implement
|
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
|
void delCmd(char ** str) { //TODO: implement
|
||||||
printf("removed %s \n", *str);
|
printf("removed %s \n", *str);
|
||||||
|
|||||||
Reference in New Issue
Block a user