forked from captain-n3m0/Kernel16F
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
311942b
commit 951fd09
Showing
7 changed files
with
93 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include "cli.h" | ||
#include "display.h" | ||
|
||
void echo(char* args[]) { | ||
char output[100] = ""; | ||
for (int i = 0; args[i] != NULL; i++) { | ||
strcat(output, args[i]); | ||
strcat(output, " "); | ||
} | ||
strcat(output, "\n"); | ||
display_write(output); | ||
} | ||
|
||
void help(char* args[]) { | ||
char output[100] = ""; | ||
strcat(output, "Available commands:\n"); | ||
strcat(output, "echo [args...]\n"); | ||
strcat(output, "help\n"); | ||
strcat(output, "version\n"); | ||
display_write(output); | ||
} | ||
|
||
void version(char* args[]) { | ||
char output[100] = ""; | ||
strcat(output, "Kernel16F version 1.0\n"); | ||
display_write(output); | ||
} | ||
|
||
void cli_init() { | ||
display_init(); | ||
} | ||
|
||
void cli_parse_input(char* input_str) { | ||
char* args[10]; | ||
char* token = strtok(input_str, " "); | ||
int i = 0; | ||
while (token != NULL) { | ||
args[i++] = token; | ||
token = strtok(NULL, " "); | ||
} | ||
args[i] = NULL; | ||
|
||
if (strcmp(args[0], "echo") == 0) { | ||
echo(&args[1]); | ||
} else if (strcmp(args[0], "help") == 0) { | ||
help(&args[1]); | ||
} else if (strcmp(args[0], "version") == 0) { | ||
version(&args[1]); | ||
} else { | ||
char output[100] = ""; | ||
strcat(output, "Invalid command. Type 'help' for a list of available commands.\n"); | ||
display_write(output); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef CLI_H | ||
#define CLI_H | ||
|
||
void cli_init(); | ||
void cli_parse_input(char* input_str); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <stdio.h> | ||
#include "display.h" | ||
|
||
void display_init() { | ||
// Initialize the display output | ||
} | ||
|
||
void display_write(char* str) { | ||
printf("%s", str); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef DISPLAY_H | ||
#define DISPLAY_H | ||
|
||
void display_init(); | ||
void display_write(char* str); | ||
|
||
#endif |