WallShell
An easy-to-use, highly portable, CLI using C99.
ws_command_t Struct Reference

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...
 

Detailed Description

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.

Field Documentation

◆ aliases

aliases

Any aliases you want your command to have.

When typed, these call your command as if they are the normal Command Name.

Warning
Make sure to not declare this in context. If declared in context, and that scope is exited, WallShell will be trying to read non-existent entries, likely causing a segfault. Create this array using malloc (or calloc) if available, or declare it in a global scope.

◆ aliases_count

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

commandName

Name of the command.

This is what the user has to type into the terminal to run your command.

◆ helpCommand

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

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.


The documentation for this struct was generated from the following files: