initial command shell implementation

almost all commands are not yet implemented.

actual communication hooks are not yet implemented.
This commit is contained in:
true
2024-11-06 22:03:59 -08:00
parent 2bee391469
commit d6e68ce761
26 changed files with 6250 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
/*
* cons_about.h
*
* Created on: Nov 6, 2024
* Author: true
*/
#ifndef USER_SHELL_COMMANDS_ABOUT_H_
#define USER_SHELL_COMMANDS_ABOUT_H_
static const char about[] = "true's GAT Stand\n"
"a device for displaying badge addons\n"
"compatible with GAT, SAOv1, SAOv1.69bis standards\n\n"
"code and hardware design by true\n"
"manual and info at https://basic.truecontrol.org\n\n";
void cons_about(int argc, char **argv)
{
if (!argc) {
CONS_PRINT("...just do it.");
return;
}
CONS_PRINT(about);
}
#endif /* USER_SHELL_COMMANDS_ABOUT_H_ */

View File

@@ -0,0 +1,25 @@
/*
* cons_cls.h
*
* Created on: Nov 6, 2024
* Author: true
*/
#ifndef USER_SHELL_COMMANDS_CLS_H_
#define USER_SHELL_COMMANDS_CLS_H_
void cons_cls(int argc, char **argv)
{
if (!argc) {
CONS_PRINT("...clears the screen. just try it.");
return;
}
CONS_PRINT("\x1B[2J\x1B[0;0H");
}
#endif /* USER_SHELL_COMMANDS_CLS_H_ */

View File

@@ -0,0 +1,65 @@
/*
* cons_help.h
*
* Created on: Nov 6, 2024
* Author: true
*/
#ifndef USER_SHELL_COMMANDS_HELP_H_
#define USER_SHELL_COMMANDS_HELP_H_
void cons_help_real(int argc, char **argv, command_table_t *p)
{
int i;
if (argc < 2) {
// print help list
if ((shell_flags & 0x02) == 0) {
CONS_PRINT("Tip: You only need to use the first two characters ");
CONS_PRINT("of a command.\r\n\r\n");
shell_flags |= 0x02;
}
while (p->cmd != 0) {
if (strlen(p->desc)) {
strcpy( console_line, "* ");
strncat(console_line, p->cmd, 12);
for (i = strlen(console_line); i <= 12; i++) {
console_line[i] = 0x20;
}
console_line[i] = 0x00;
strncat(console_line, p->desc, 77);
strncat(console_line, "\r\n", 79);
console_line[63] = 0;
CONS_PRINT(console_line);
}
p++;
}
} else {
while (p->cmd != 0) {
// calling the callback with argc/argv set to 0 should instruct it to print help/usage
if (strcmp(argv[1], p->cmd) == 0) {
p->go(0, (char **)0);
return;
}
p++;
}
// looks like the command wasn't found
strcpy( console_line, "* no help found for command called '");
strncat(console_line, argv[1], 60);
strncat(console_line, "'\r\n", 62);
CONS_PRINT(console_line);
}
}
void cons_help(int argc, char **argv)
{
cons_help_real(argc, argv, (command_table_t *)console_cmdlist);
}
#endif /* USER_SHELL_COMMANDS_HELP_H_ */