c-template
command_line.h File Reference

provides a basic CLI building tool attribution note: modified version of commander see deps/commander for the license for that package uses argtable3 for command line configuration and allows loading a list of commands to execute using the --conmmand or -c CLI flag you can specify the command out of the list of commands that have been loaded before calling execute you'll want to load the appropriate argc and argv values for the callback of the command you want to make More...

#include <argtable3.h>
#include <stdbool.h>
Include dependency graph for command_line.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  command_handler
 
struct  command
 

Macros

#define MAX_COMMANDS   32
 
#define MAX_COMMAND_ARGS   32
 

Typedefs

typedef void(* command_handler_callback) (int argc, char *argv[])
 
typedef struct command command_object
 

Functions

char * get_run_command ()
 returns the value of command_to_run More...
 
void setup_args (const char *version_string)
 setups the default argtable arguments More...
 
void print_help (char *program_name, void *argtable[])
 formats output More...
 
int parse_args (int argc, char *argv[], void *argtable[])
 parses arguments, and checks for any errors More...
 
int execute (command_object *self, char *command_to_run)
 checks to see if we have a command named according to run and executes it More...
 
int load_command (command_object *self, command_handler *command)
 loads command handler and makes it executable More...
 
command_objectnew_command_object (int argc, char *argv[])
 intializes a new command_object to have commands loaded into More...
 
void free_command_object (command_object *self)
 frees memory allocated for the command_object and sets pointer to null More...
 

Variables

struct arg_lit * help
 
struct arg_lit * version
 
struct arg_str * command_to_run
 
struct arg_file * file
 
struct arg_file * output
 
struct arg_end * end
 

Detailed Description

provides a basic CLI building tool attribution note: modified version of commander see deps/commander for the license for that package uses argtable3 for command line configuration and allows loading a list of commands to execute using the --conmmand or -c CLI flag you can specify the command out of the list of commands that have been loaded before calling execute you'll want to load the appropriate argc and argv values for the callback of the command you want to make

Definition in file command_line.h.

Macro Definition Documentation

◆ MAX_COMMAND_ARGS

#define MAX_COMMAND_ARGS   32

Definition at line 22 of file command_line.h.

◆ MAX_COMMANDS

#define MAX_COMMANDS   32

Definition at line 18 of file command_line.h.

Typedef Documentation

◆ command_handler_callback

typedef void(* command_handler_callback) (int argc, char *argv[])

Definition at line 35 of file command_line.h.

◆ command_object

typedef struct command command_object

Function Documentation

◆ execute()

int execute ( command_object self,
char *  command_to_run 
)

checks to see if we have a command named according to run and executes it

Definition at line 59 of file command_line.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_command_object()

void free_command_object ( command_object self)

frees memory allocated for the command_object and sets pointer to null

frees memory allocated for the command_object and sets pointer to null

Definition at line 74 of file command_line.c.

Here is the caller graph for this function:

◆ get_run_command()

char* get_run_command ( )

returns the value of command_to_run

Definition at line 115 of file command_line.c.

◆ load_command()

int load_command ( command_object self,
command_handler command 
)

loads command handler and makes it executable

Definition at line 47 of file command_line.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ new_command_object()

command_object* new_command_object ( int  argc,
char *  argv[] 
)

intializes a new command_object to have commands loaded into

Definition at line 14 of file command_line.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_args()

int parse_args ( int  argc,
char *  argv[],
void *  argtable[] 
)

parses arguments, and checks for any errors

Definition at line 82 of file command_line.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_help()

void print_help ( char *  program_name,
void *  argtable[] 
)

formats output

Definition at line 99 of file command_line.c.

Here is the caller graph for this function:

◆ setup_args()

void setup_args ( const char *  version_string)

setups the default argtable arguments

Definition at line 106 of file command_line.c.

Here is the caller graph for this function:

Variable Documentation

◆ command_to_run

struct arg_str* command_to_run

Definition at line 27 of file command_line.h.

◆ end

struct arg_end* end

Definition at line 29 of file command_line.h.

◆ file

struct arg_file* file

Definition at line 28 of file command_line.h.

◆ help

struct arg_lit* help

Definition at line 26 of file command_line.h.

◆ output

struct arg_file * output

Definition at line 28 of file command_line.h.

◆ version

struct arg_lit * version

Definition at line 26 of file command_line.h.