c-template
|
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>
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_object * | new_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 |
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.
#define MAX_COMMAND_ARGS 32 |
Definition at line 22 of file command_line.h.
#define MAX_COMMANDS 32 |
Definition at line 18 of file command_line.h.
typedef void(* command_handler_callback) (int argc, char *argv[]) |
Definition at line 35 of file command_line.h.
typedef struct command command_object |
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.
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.
char* get_run_command | ( | ) |
returns the value of command_to_run
Definition at line 115 of file command_line.c.
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.
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.
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.
void print_help | ( | char * | program_name, |
void * | argtable[] | ||
) |
formats output
Definition at line 99 of file command_line.c.
void setup_args | ( | const char * | version_string | ) |
setups the default argtable arguments
Definition at line 106 of file command_line.c.
struct arg_str* command_to_run |
Definition at line 27 of file command_line.h.
struct arg_end* end |
Definition at line 29 of file command_line.h.
struct arg_file* file |
Definition at line 28 of file command_line.h.
struct arg_lit* help |
Definition at line 26 of file command_line.h.
struct arg_file * output |
Definition at line 28 of file command_line.h.
struct arg_lit * version |
Definition at line 26 of file command_line.h.