abt to big refactor
This commit is contained in:
22
src/main.c
22
src/main.c
@ -7,13 +7,29 @@
|
||||
|
||||
#include "console/console.h"
|
||||
#include "server/server.h"
|
||||
#include "util/string.h"
|
||||
|
||||
bool_t exitRequested = false;
|
||||
|
||||
void cmdExit(const consolecmdexec_t *exec) {
|
||||
CloseWindow();
|
||||
exitRequested = true;
|
||||
}
|
||||
|
||||
void cmdServe(const consolecmdexec_t *exec) {
|
||||
serverStart(3030);
|
||||
uint16_t port = 3030;
|
||||
if(exec->argc != 0) {
|
||||
if(!stringToU16(exec->argv[0], &port)) {
|
||||
consolePrint("Invalid port number: %s", exec->argv[0]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
errorret_t ret = serverStart(port);
|
||||
if(ret != ERROR_OK) {
|
||||
consolePrint("Failed to start server: %s", errorString());
|
||||
errorFlush();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void cmdClose(const consolecmdexec_t *exec) {
|
||||
@ -39,6 +55,8 @@ int main(void) {
|
||||
consoleDraw();
|
||||
|
||||
EndDrawing();
|
||||
|
||||
if(exitRequested) break;
|
||||
}
|
||||
|
||||
CloseWindow();
|
||||
|
Reference in New Issue
Block a user