WallShell
An easy-to-use, highly portable, CLI using C99.
|
Command Data Structure. More...
Data Fields | |
int(* | mainCommand )(int argc, char **argv) |
Main function of the command. More... | |
int(* | helpCommand )(int argc, char **argv) |
Help function of the command. More... | |
const char * | commandName |
Name of the command. More... | |
const char ** | aliases |
Any aliases you want your command to have. More... | |
size_t | aliases_count |
Amount of aliases in your alias array. More... | |
Command Data Structure.
This structure holds all data related to the command. There are two required entries, mainCommand
and commandName
. The rest of the structures are optional, and if they are unused should be set to NULL
, nullptr
, or 0
respectively.
aliases |
Any aliases you want your command to have.
When typed, these call your command as if they are the normal Command Name.
aliases_count |
Amount of aliases in your alias array.
This should act like strlen, it's the count, not the indexes. If this number is inaccurate, WallShell will either not read all you entries (if count is too small) or create a buffer overflow (and likely a segfault).
commandName |
Name of the command.
This is what the user has to type into the terminal to run your command.
helpCommand |
Help function of the command.
This is not required. This is called when help <command>
is called.
Should be a pointer to a C style main function. This means it needs to be in the form int func(int argc, char** argv);
If you are using this in C++, you will have to mark it extern "C"
, and may have to do some trickery if it's part of a class. argc
and argv
work identically to those in the C-standard. The return code is displayed to terminal if it isn't 0.
mainCommand |
Main function of the command.
This is called when your command is written in terminal.
Should be a pointer to a C style main function. This means it needs to be in the form int func(int argc, char** argv);
If you are using this in C++, you will have to mark it extern "c"
, and may have to do some trickery if it's part of a class. argc
and argv
work identically to those in the C-standard. The return code is displayed to terminal if it isn't 0.