ZClk  0.1.0-alpha.3
Library to build cli programs
Data Structures | Macros | Typedefs | Enumerations | Functions
zclk.h File Reference

Zclk main header file. Defines the Public API of zclk. More...

#include "zclk_common.h"
#include <coll_arraylist.h>
#include "zclk_table.h"
#include "zclk_dict.h"
#include "zclk_progress.h"
Include dependency graph for zclk.h:

Go to the source code of this file.

Data Structures

struct  zclk_val_t
 This struct holds the value of the argument or option. More...
 
struct  zclk_option_t
 CLI Option Object. More...
 
struct  zclk_argument_t
 CLI Argument object. More...
 
struct  zclk_command_t
 A CLI Command Ojbect. More...
 

Macros

#define ZCLK_OPTION_HELP_LONG   "help"
 
#define ZCLK_OPTION_HELP_SHORT   "h"
 
#define ZCLK_OPTION_HELP_DESC   "Print help for command."
 
#define ZCLK_BOOL_TRUE   1
 
#define ZCLK_BOOL_FALSE   0
 
#define ZCLK_FLAG_ON   1
 
#define ZCLK_FLAG_OFF   0
 
#define zclk_val_is_bool(val)   zclk_val_is_type(val, ZCLK_TYPE_BOOLEAN)
 Check if given value is boolean. More...
 
#define zclk_val_is_int(val)   zclk_val_is_type(val, ZCLK_TYPE_INT)
 Check if given value is int. More...
 
#define zclk_val_is_double(val)   zclk_val_is_type(val, ZCLK_TYPE_DOUBLE)
 Check if given value is double. More...
 
#define zclk_val_is_string(val)   zclk_val_is_type(val, ZCLK_TYPE_STRING)
 Check if given value is string. More...
 
#define zclk_val_is_flag(val)   zclk_val_is_type(val, ZCLK_TYPE_FLAG)
 Check if given value is flag. More...
 
#define zclk_flag(v)   new_zclk_val_flag(v)
 Create a new flag cli value. More...
 
#define zclk_boolean(v)   new_zclk_val_bool(v)
 Create a new boolean cli value. More...
 
#define zclk_int(v)   new_zclk_val_int(v)
 Create a new integer cli value. More...
 
#define zclk_double(v)   new_zclk_val_double(v)
 Create a new double cli value. More...
 
#define zclk_string(v)   new_zclk_val_string(v)
 Create a new string cli value. More...
 
#define zclk_command_option_foreach(cmd, opt)
 Iterator for options of the given command. More...
 
#define zclk_command_argument_foreach(cmd, arg)
 Iterator for arguments of the given command. More...
 

Typedefs

typedef struct zclk_val_t zclk_val
 This struct holds the value of the argument or option.
 
typedef struct zclk_option_t zclk_option
 CLI Option Object.
 
typedef struct zclk_argument_t zclk_argument
 CLI Argument object.
 
typedef zclk_res(* zclk_command_output_handler) (zclk_res result_flag, zclk_result_type result_type, void *result)
 Defines a function to handle command output.
 
typedef zclk_res(* zclk_command_fn) (struct zclk_command_t *cmd, void *handler_args)
 defines a function to run a command
 
typedef struct zclk_command_t zclk_command
 A CLI Command Ojbect.
 

Enumerations

enum  zclk_res {
  ZCLK_RES_IS_RUNNING = -1 , ZCLK_RES_SUCCESS = 0 , ZCLK_RES_ERR_UNKNOWN = 1 , ZCLK_RES_ERR_ALLOC_FAILED = 2 ,
  ZCLK_RES_ERR_COMMAND_NOT_FOUND = 3 , ZCLK_RES_ERR_OPTION_NOT_FOUND = 4 , ZCLK_RES_ERR_ARG_NOT_FOUND = 5 , ZCLK_RES_ERR_EXTRA_ARGS_FOUND = 6
}
 This enum defines the possible error codes generated by functions in the API.
 
enum  zclk_type {
  ZCLK_TYPE_BOOLEAN = 0 , ZCLK_TYPE_INT = 1 , ZCLK_TYPE_DOUBLE = 2 , ZCLK_TYPE_STRING = 3 ,
  ZCLK_TYPE_FLAG = 4
}
 This enum defines the possible datatypes of argument or option values.
 
enum  zclk_result_type { ZCLK_RESULT_STRING = 0 , ZCLK_RESULT_TABLE = 1 , ZCLK_RESULT_DICT = 2 , ZCLK_RESULT_PROGRESS = 3 }
 This enum defines the possible types of result cli program might output.
 

Functions

MODULE_API int zclk_val_is_type (zclk_val *val, zclk_type type)
 
MODULE_API int zclk_val_get_bool (zclk_val *val)
 get the boolean value More...
 
MODULE_API int zclk_val_get_int (zclk_val *val)
 get the int value More...
 
MODULE_API double zclk_val_get_double (zclk_val *val)
 get the double value More...
 
MODULE_API const char * zclk_val_get_string (zclk_val *val)
 get the string value More...
 
MODULE_API int zclk_val_get_flag (zclk_val *val)
 get the flag value More...
 
MODULE_API void zclk_val_set_bool (zclk_val *val, int bval)
 set the boolean value More...
 
MODULE_API void zclk_val_set_int (zclk_val *val, int ival)
 set the int value More...
 
MODULE_API void zclk_val_set_dobule (zclk_val *val, double dval)
 set the double value More...
 
MODULE_API void zclk_val_set_string (zclk_val *val, const char *sval)
 set the string value More...
 
MODULE_API void zclk_val_set_flag (zclk_val *val, int fval)
 set the flag value More...
 
MODULE_API zclk_valnew_zclk_val_bool (int bool_val)
 Create a new boolean value. More...
 
MODULE_API zclk_valnew_zclk_val_int (int int_val)
 Create a new int value. More...
 
MODULE_API zclk_valnew_zclk_val_double (double double_val)
 Create a new double value. More...
 
MODULE_API zclk_valnew_zclk_val_string (const char *string_val)
 Create a new string value. More...
 
MODULE_API zclk_valnew_zclk_val_flag (int flag_val)
 Create a new flag value. More...
 
MODULE_API void zclk_fill_options_in_list (arraylist *optlist, zclk_option *options[])
 Fill the entries in the given option array into an arraylist. More...
 
MODULE_API zclk_res make_zclk_val (zclk_val **val, zclk_type type)
 
MODULE_API void free_zclk_val (zclk_val *val)
 
MODULE_API void clear_zclk_val (zclk_val *val)
 
MODULE_API void copy_zclk_val (zclk_val *to, zclk_val *from)
 
MODULE_API zclk_res parse_zclk_val (zclk_val *val, char *input)
 
MODULE_API zclk_res make_option (zclk_option **option, const char *name, const char *short_name, zclk_val *val, zclk_val *default_val, const char *description)
 
MODULE_API zclk_optionnew_zclk_option (const char *name, const char *short_name, zclk_val *val, zclk_val *default_val, const char *desc)
 (Internal Use) Create an option object More...
 
MODULE_API zclk_optionnew_zclk_option_bool (const char *name, const char *short_name, int default_val, const char *desc)
 
MODULE_API zclk_optionnew_zclk_option_int (const char *name, const char *short_name, int default_val, const char *desc)
 
MODULE_API zclk_optionnew_zclk_option_double (const char *name, const char *short_name, double default_val, const char *desc)
 
MODULE_API zclk_optionnew_zclk_option_string (const char *name, const char *short_name, const char *default_val, const char *desc)
 
MODULE_API zclk_optionnew_zclk_option_flag (const char *name, const char *short_name, int default_val, const char *desc)
 
MODULE_API const char * zclk_option_get_name (zclk_option *opt)
 
MODULE_API const char * zclk_option_get_short_name (zclk_option *opt)
 
MODULE_API const char * zclk_option_get_desc (zclk_option *opt)
 
MODULE_API int zclk_option_get_val_bool (zclk_option *opt)
 
MODULE_API int zclk_option_get_val_int (zclk_option *opt)
 
MODULE_API double zclk_option_get_val_double (zclk_option *opt)
 
MODULE_API const char * zclk_option_get_val_string (zclk_option *opt)
 
MODULE_API int zclk_option_get_val_flag (zclk_option *opt)
 
MODULE_API int zclk_option_get_default_val_bool (zclk_option *opt)
 
MODULE_API int zclk_option_get_default_val_int (zclk_option *opt)
 
MODULE_API double zclk_option_get_default_val_double (zclk_option *opt)
 
MODULE_API const char * zclk_option_get_default_val_string (zclk_option *opt)
 
MODULE_API int zclk_option_get_default_val_flag (zclk_option *opt)
 
MODULE_API void free_option (zclk_option *option)
 
MODULE_API zclk_optionget_option_by_name (arraylist *options, const char *name)
 Get the option by name object. More...
 
MODULE_API zclk_res make_argument (zclk_argument **arg, const char *name, zclk_val *val, zclk_val *default_val, const char *desc)
 
MODULE_API zclk_argumentnew_zclk_argument (const char *name, zclk_val *val, zclk_val *default_val, const char *desc, int nargs)
 (Internal use) Create an argument object More...
 
MODULE_API zclk_argumentnew_zclk_argument_bool (const char *name, int default_val, const char *desc, int nargs)
 
MODULE_API zclk_argumentnew_zclk_argument_int (const char *name, int default_val, const char *desc, int nargs)
 
MODULE_API zclk_argumentnew_zclk_argument_double (const char *name, double default_val, const char *desc, int nargs)
 
MODULE_API zclk_argumentnew_zclk_argument_string (const char *name, const char *default_val, const char *desc, int nargs)
 
MODULE_API zclk_argumentnew_zclk_argument_flag (const char *name, int default_val, const char *desc, int nargs)
 
MODULE_API const char * zclk_argument_get_name (zclk_argument *opt)
 
MODULE_API const char * zclk_argument_get_desc (zclk_argument *opt)
 
MODULE_API int zclk_argument_get_val_bool (zclk_argument *opt)
 
MODULE_API int zclk_argument_get_val_int (zclk_argument *opt)
 
MODULE_API double zclk_argument_get_val_double (zclk_argument *opt)
 
MODULE_API const char * zclk_argument_get_val_string (zclk_argument *opt)
 
MODULE_API int zclk_argument_get_val_flag (zclk_argument *opt)
 
MODULE_API int zclk_argument_get_default_val_bool (zclk_argument *opt)
 
MODULE_API int zclk_argument_get_default_val_int (zclk_argument *opt)
 
MODULE_API double zclk_argument_get_default_val_double (zclk_argument *opt)
 
MODULE_API const char * zclk_argument_get_default_val_string (zclk_argument *opt)
 
MODULE_API int zclk_argument_get_default_val_flag (zclk_argument *opt)
 
MODULE_API void free_argument (zclk_argument *arg)
 
MODULE_API zclk_res make_command (zclk_command **command, const char *name, const char *short_name, const char *description, zclk_command_fn handler)
 
MODULE_API zclk_commandnew_zclk_command (const char *name, const char *short_name, const char *description, zclk_command_fn handler)
 Create a command object with automatic error handling. More...
 
MODULE_API zclk_res zclk_command_subcommand_add (zclk_command *cmd, zclk_command *subcommand)
 Add a subcommand to the given command. More...
 
MODULE_API zclk_res zclk_command_option_add (zclk_command *cmd, zclk_option *option)
 Add an option to the given command. More...
 
MODULE_API zclk_res zclk_command_argument_add (zclk_command *cmd, zclk_argument *arg)
 Add an argument to the given command. More...
 
MODULE_API void zclk_command_bool_option (zclk_command *cmd, const char *name, const char *short_name, const char *desc)
 Create a new boolean option and add it to the given command. More...
 
MODULE_API void zclk_command_int_option (zclk_command *cmd, const char *name, const char *short_name, int default_val, const char *desc)
 Create a new int option and add it to the given command. More...
 
MODULE_API void zclk_command_double_option (zclk_command *cmd, const char *name, const char *short_name, double default_val, const char *desc)
 Create a new double option and add it to the given command. More...
 
MODULE_API void zclk_command_string_option (zclk_command *cmd, const char *name, const char *short_name, const char *default_val, const char *desc)
 Create a new string option and add it to the given command. More...
 
MODULE_API void zclk_command_flag_option (zclk_command *cmd, const char *name, const char *short_name, const char *desc)
 Create a new flag option and add it to the given command. More...
 
MODULE_API void zclk_command_bool_argument (zclk_command *cmd, const char *name, int default_val, const char *desc, int nargs)
 Create a new bool argument and add it to the given command. More...
 
MODULE_API void zclk_command_int_argument (zclk_command *cmd, const char *name, int default_val, const char *desc, int nargs)
 Create a new bool argument and add it to the given command. More...
 
MODULE_API void zclk_command_double_argument (zclk_command *cmd, const char *name, double default_val, const char *desc, int nargs)
 Create a new bool argument and add it to the given command. More...
 
MODULE_API void zclk_command_string_argument (zclk_command *cmd, const char *name, const char *default_val, const char *desc, int nargs)
 Create a new bool argument and add it to the given command. More...
 
MODULE_API void zclk_command_flag_argument (zclk_command *cmd, const char *name, int default_val, const char *desc, int nargs)
 Create a new bool argument and add it to the given command. More...
 
MODULE_API zclk_optionzclk_command_get_option (zclk_command *cmd, const char *name)
 Get the option object corresponding to given name. More...
 
MODULE_API zclk_argumentzclk_command_get_argument (zclk_command *cmd, const char *name)
 Get the argument object corresponding to given name. More...
 
MODULE_API zclk_res zclk_command_exec (zclk_command *cmd, void *exec_args, int argc, char *argv[])
 Execute the command with the given args. More...
 
MODULE_API void free_command (zclk_command *command)
 
MODULE_API char * get_help_for_command (arraylist *cmds_to_exec)
 
MODULE_API zclk_res help_cmd_handler (arraylist *commands, void *handler_args, int argc, char **argv, zclk_command_output_handler success_handler, zclk_command_output_handler error_handler)
 
MODULE_API zclk_res get_help_for (char **help_str, arraylist *commands, arraylist *arg_commands)
 
MODULE_API zclk_res exec_command (arraylist *commands, void *handler_args, int argc, char **argv)
 
MODULE_API void print_table_result (void *result)
 Print a tabular result object to the stdout. More...
 
MODULE_API zclk_res print_handler (zclk_res result_flag, zclk_result_type res_type, void *result)
 A Print handler prints the result of the command. More...
 

Detailed Description

Zclk main header file. Defines the Public API of zclk.

Macro Definition Documentation

◆ zclk_boolean

#define zclk_boolean (   v)    new_zclk_val_bool(v)

Create a new boolean cli value.

Parameters
vvalue

◆ zclk_command_argument_foreach

#define zclk_command_argument_foreach (   cmd,
  arg 
)
Value:
zclk_argument *arg = NULL; \
size_t len##arg = arraylist_length(cmd->args); \
for (size_t i = 0; ((i < len##arg)? \
(arg = (zclk_argument *) \
(arraylist_get(cmd->args, i))) \
: 0); \
i++)
CLI Argument object.
Definition: zclk.h:343

Iterator for arguments of the given command.

Parameters
cmdcommand object
argname of the argument which will contain an argument in every iteration.

◆ zclk_command_option_foreach

#define zclk_command_option_foreach (   cmd,
  opt 
)
Value:
zclk_option *opt = NULL; \
size_t len##opt = arraylist_length(cmd->options); \
for (size_t i = 0; ((i < len##opt)? \
(opt = (zclk_option *) \
(arraylist_get(cmd->options, i))) \
: 0); \
i++)
CLI Option Object.
Definition: zclk.h:311

Iterator for options of the given command.

Parameters
cmdcommand object
optname of the argument which will contain an option in every iteration.

◆ zclk_double

#define zclk_double (   v)    new_zclk_val_double(v)

Create a new double cli value.

Parameters
vvalue

◆ zclk_flag

#define zclk_flag (   v)    new_zclk_val_flag(v)

Create a new flag cli value.

Parameters
vvalue

◆ zclk_int

#define zclk_int (   v)    new_zclk_val_int(v)

Create a new integer cli value.

Parameters
vvalue

◆ ZCLK_OPTION_HELP_DESC

#define ZCLK_OPTION_HELP_DESC   "Print help for command."

Help option description

◆ ZCLK_OPTION_HELP_LONG

#define ZCLK_OPTION_HELP_LONG   "help"

Help option long name

◆ ZCLK_OPTION_HELP_SHORT

#define ZCLK_OPTION_HELP_SHORT   "h"

Help option short name

◆ zclk_string

#define zclk_string (   v)    new_zclk_val_string(v)

Create a new string cli value.

Parameters
vvalue

◆ zclk_val_is_bool

#define zclk_val_is_bool (   val)    zclk_val_is_type(val, ZCLK_TYPE_BOOLEAN)

Check if given value is boolean.

Parameters
valvalue object
Returns
flag indicating if value is boolean

◆ zclk_val_is_double

#define zclk_val_is_double (   val)    zclk_val_is_type(val, ZCLK_TYPE_DOUBLE)

Check if given value is double.

Parameters
valvalue object
Returns
flag indicating if value is double

◆ zclk_val_is_flag

#define zclk_val_is_flag (   val)    zclk_val_is_type(val, ZCLK_TYPE_FLAG)

Check if given value is flag.

Parameters
valvalue object
Returns
flag indicating if value is flag

◆ zclk_val_is_int

#define zclk_val_is_int (   val)    zclk_val_is_type(val, ZCLK_TYPE_INT)

Check if given value is int.

Parameters
valvalue object
Returns
flag indicating if value is int

◆ zclk_val_is_string

#define zclk_val_is_string (   val)    zclk_val_is_type(val, ZCLK_TYPE_STRING)

Check if given value is string.

Parameters
valvalue object
Returns
flag indicating if value is string

Function Documentation

◆ clear_zclk_val()

MODULE_API void clear_zclk_val ( zclk_val val)

Reset values to system defaults.

◆ copy_zclk_val()

MODULE_API void copy_zclk_val ( zclk_val to,
zclk_val from 
)

Copy values from 'from' to 'to'. Can be used to reset to defaults.

Parameters
toval to set
fromval to read from

◆ exec_command()

MODULE_API zclk_res exec_command ( arraylist *  commands,
void *  handler_args,
int  argc,
char **  argv 
)

Execute a single line containing one top-level command. All output is written to stdout, all errors to stderr

Parameters
commandsthe list of commands registered (this is a list of zclk_command*)
handler_argsan args value to be passed to the command handler
argcthe number of tokens in the line
argvargs as an array of strings

◆ free_argument()

MODULE_API void free_argument ( zclk_argument arg)

Free resources used by argument

◆ free_command()

MODULE_API void free_command ( zclk_command command)

Free a command object

Parameters
commandcommand object to free

◆ free_option()

MODULE_API void free_option ( zclk_option option)

Free resources used by option

Parameters
optionto free

◆ free_zclk_val()

MODULE_API void free_zclk_val ( zclk_val val)

Free the created value

◆ get_help_for()

MODULE_API zclk_res get_help_for ( char **  help_str,
arraylist *  commands,
arraylist *  arg_commands 
)

Get the help string for the arg_commands from the registered commands list.

Parameters
help_strthe help string to return
commandsis the configured list of commands
arg_commandsis a list of string
Returns
error code

◆ get_help_for_command()

MODULE_API char* get_help_for_command ( arraylist *  cmds_to_exec)

Get help for a command

Parameters
cmds_to_execthe list of commands and subcommands parsed
Returns
string with command help

◆ get_option_by_name()

MODULE_API zclk_option* get_option_by_name ( arraylist *  options,
const char *  name 
)

Get the option by name object.

Parameters
optionsoptions list
namename of option to retrieve
Returns
zclk_option* option with the given name

◆ help_cmd_handler()

MODULE_API zclk_res help_cmd_handler ( arraylist *  commands,
void *  handler_args,
int  argc,
char **  argv,
zclk_command_output_handler  success_handler,
zclk_command_output_handler  error_handler 
)

Run the help command for all commands or single command

Parameters
commandsthe list of commands registered (this is a list of zclk_command*)
handler_argsan args value to be passed to the command handler
argcthe number of tokens in the line
argvargs as an array of strings
success_handlerhandle success results
error_handlerhandler error results

◆ make_argument()

MODULE_API zclk_res make_argument ( zclk_argument **  arg,
const char *  name,
zclk_val val,
zclk_val default_val,
const char *  desc 
)

(Internal Use) Create a new argument given a name and type.

NOTE: For most usecases use the type specific argument creation functions called new_zclk_argument_<type>() . Here type can be one of bool, int flag, double or string.

Parameters
argobject to create
name
val
default_val
desc
Returns
error code

◆ make_command()

MODULE_API zclk_res make_command ( zclk_command **  command,
const char *  name,
const char *  short_name,
const char *  description,
zclk_command_fn  handler 
)

Create a new command with the given name and handler Options and sub-commands need to be added after creation. The sub-commands, arguments and options lists will be initialized, so one just needs to add items using the arraylist add function.

Parameters
commandobj to be created
name
short_name
description
handlerfunction ptr to handler
Returns
error code

◆ make_option()

MODULE_API zclk_res make_option ( zclk_option **  option,
const char *  name,
const char *  short_name,
zclk_val val,
zclk_val default_val,
const char *  description 
)

(Internal Use) Create a new option given a name and type.

Parameters
optionobject to create
name
short_name
val
default_val
description
Returns
error code

◆ make_zclk_val()

MODULE_API zclk_res make_zclk_val ( zclk_val **  val,
zclk_type  type 
)

Create a new value object of given type.

Parameters
valobject to create
type
Returns
error code

◆ new_zclk_argument()

MODULE_API zclk_argument* new_zclk_argument ( const char *  name,
zclk_val val,
zclk_val default_val,
const char *  desc,
int  nargs 
)

(Internal use) Create an argument object

NOTE: For most usecases use the type specific argument creation functions called new_zclk_argument_<type>() . Here type can be one of bool, int flag, double or string.

Parameters
name
val
default_val
desc
nargs
Returns
argument object

◆ new_zclk_command()

MODULE_API zclk_command* new_zclk_command ( const char *  name,
const char *  short_name,
const char *  description,
zclk_command_fn  handler 
)

Create a command object with automatic error handling.

See also
make_command
Parameters
name
short_name
description
handler
Returns
zclk_command* created command object

◆ new_zclk_option()

MODULE_API zclk_option* new_zclk_option ( const char *  name,
const char *  short_name,
zclk_val val,
zclk_val default_val,
const char *  desc 
)

(Internal Use) Create an option object

NOTE: For most usecases use the type specific option creation functions called new_zclk_option_<type>() . Here type can be one of bool, int flag, double or string.

Parameters
namename of the option
short_nameshort name
valvalue object
default_valdefault value object
descdescription
Returns
MODULE_API*

◆ new_zclk_val_bool()

MODULE_API zclk_val* new_zclk_val_bool ( int  bool_val)

Create a new boolean value.

Parameters
bool_valvalue
Returns
value object

◆ new_zclk_val_double()

MODULE_API zclk_val* new_zclk_val_double ( double  double_val)

Create a new double value.

Parameters
double_valvalue
Returns
value object

◆ new_zclk_val_flag()

MODULE_API zclk_val* new_zclk_val_flag ( int  flag_val)

Create a new flag value.

Parameters
flag_valvalue
Returns
value object

◆ new_zclk_val_int()

MODULE_API zclk_val* new_zclk_val_int ( int  int_val)

Create a new int value.

Parameters
int_valvalue
Returns
value object

◆ new_zclk_val_string()

MODULE_API zclk_val* new_zclk_val_string ( const char *  string_val)

Create a new string value.

Parameters
string_valvalue
Returns
value object

◆ parse_zclk_val()

MODULE_API zclk_res parse_zclk_val ( zclk_val val,
char *  input 
)

Parse the input and read the value of the type of the val object. (Should not be called when the values is a flag.) The value should be set as soon as the argument/option is seen

Parameters
valobject whose value will be set
inputstring input
Returns
error code

◆ print_handler()

MODULE_API zclk_res print_handler ( zclk_res  result_flag,
zclk_result_type  res_type,
void *  result 
)

A Print handler prints the result of the command.

Parameters
result_flagerror flag
res_typeresult type
resultresult object
Returns
error code

◆ print_table_result()

MODULE_API void print_table_result ( void *  result)

Print a tabular result object to the stdout.

Parameters
resulttable result object

◆ zclk_command_argument_add()

MODULE_API zclk_res zclk_command_argument_add ( zclk_command cmd,
zclk_argument arg 
)

Add an argument to the given command.

Parameters
cmdcommand
argargument to add
Returns
error code

◆ zclk_command_bool_argument()

MODULE_API void zclk_command_bool_argument ( zclk_command cmd,
const char *  name,
int  default_val,
const char *  desc,
int  nargs 
)

Create a new bool argument and add it to the given command.

Parameters
cmdcommand object
namename of the argument
default_valdefault value
desctext description
nargsnumber of occurences (-1 means unlimited occurences)

◆ zclk_command_bool_option()

MODULE_API void zclk_command_bool_option ( zclk_command cmd,
const char *  name,
const char *  short_name,
const char *  desc 
)

Create a new boolean option and add it to the given command.

Parameters
cmdcommand object
namename of the option
short_nameshort name of the option
desctext description

◆ zclk_command_double_argument()

MODULE_API void zclk_command_double_argument ( zclk_command cmd,
const char *  name,
double  default_val,
const char *  desc,
int  nargs 
)

Create a new bool argument and add it to the given command.

Parameters
cmdcommand object
namename of the argument
default_valdefault value
desctext description
nargsnumber of occurences (-1 means unlimited occurences)

◆ zclk_command_double_option()

MODULE_API void zclk_command_double_option ( zclk_command cmd,
const char *  name,
const char *  short_name,
double  default_val,
const char *  desc 
)

Create a new double option and add it to the given command.

Parameters
cmdcommand object
namename of the option
short_nameshort name of the option
default_valdefault value
desctext description

◆ zclk_command_exec()

MODULE_API zclk_res zclk_command_exec ( zclk_command cmd,
void *  exec_args,
int  argc,
char *  argv[] 
)

Execute the command with the given args.

Parameters
cmdCommand to execute
exec_argsexec args
argcarg count
argvarg values
Returns
error code

◆ zclk_command_flag_argument()

MODULE_API void zclk_command_flag_argument ( zclk_command cmd,
const char *  name,
int  default_val,
const char *  desc,
int  nargs 
)

Create a new bool argument and add it to the given command.

Parameters
cmdcommand object
namename of the argument
default_valdefault value
desctext description
nargsnumber of occurences (-1 means unlimited occurences)

◆ zclk_command_flag_option()

MODULE_API void zclk_command_flag_option ( zclk_command cmd,
const char *  name,
const char *  short_name,
const char *  desc 
)

Create a new flag option and add it to the given command.

Parameters
cmdcommand object
namename of the option
short_nameshort name of the option
desctext description

◆ zclk_command_get_argument()

MODULE_API zclk_argument* zclk_command_get_argument ( zclk_command cmd,
const char *  name 
)

Get the argument object corresponding to given name.

Parameters
cmdcommand object
namename of the argument
Returns
zclk_argument argument if found, NULL otherwise

◆ zclk_command_get_option()

MODULE_API zclk_option* zclk_command_get_option ( zclk_command cmd,
const char *  name 
)

Get the option object corresponding to given name.

Parameters
cmdcommand object
namename of the option
Returns
zclk_option option if found, NULL otherwise

◆ zclk_command_int_argument()

MODULE_API void zclk_command_int_argument ( zclk_command cmd,
const char *  name,
int  default_val,
const char *  desc,
int  nargs 
)

Create a new bool argument and add it to the given command.

Parameters
cmdcommand object
namename of the argument
default_valdefault value
desctext description
nargsnumber of occurences (-1 means unlimited occurences)

◆ zclk_command_int_option()

MODULE_API void zclk_command_int_option ( zclk_command cmd,
const char *  name,
const char *  short_name,
int  default_val,
const char *  desc 
)

Create a new int option and add it to the given command.

Parameters
cmdcommand object
namename of the option
short_nameshort name of the option
default_valdefault value
desctext description

◆ zclk_command_option_add()

MODULE_API zclk_res zclk_command_option_add ( zclk_command cmd,
zclk_option option 
)

Add an option to the given command.

Parameters
cmdcommand
optionoption to add
Returns
error code

◆ zclk_command_string_argument()

MODULE_API void zclk_command_string_argument ( zclk_command cmd,
const char *  name,
const char *  default_val,
const char *  desc,
int  nargs 
)

Create a new bool argument and add it to the given command.

Parameters
cmdcommand object
namename of the argument
default_valdefault value
desctext description
nargsnumber of occurences (-1 means unlimited occurences)

◆ zclk_command_string_option()

MODULE_API void zclk_command_string_option ( zclk_command cmd,
const char *  name,
const char *  short_name,
const char *  default_val,
const char *  desc 
)

Create a new string option and add it to the given command.

Parameters
cmdcommand object
namename of the option
short_nameshort name of the option
default_valdefault value
desctext description

◆ zclk_command_subcommand_add()

MODULE_API zclk_res zclk_command_subcommand_add ( zclk_command cmd,
zclk_command subcommand 
)

Add a subcommand to the given command.

Parameters
cmdcommand
subcommandsubcommand to add
Returns
error code

◆ zclk_fill_options_in_list()

MODULE_API void zclk_fill_options_in_list ( arraylist *  optlist,
zclk_option options[] 
)

Fill the entries in the given option array into an arraylist.

Parameters
optlistarraylist to fill
optionsoptions array to use

◆ zclk_val_get_bool()

MODULE_API int zclk_val_get_bool ( zclk_val val)

get the boolean value

Parameters
valvalue object
Returns
boolean value

◆ zclk_val_get_double()

MODULE_API double zclk_val_get_double ( zclk_val val)

get the double value

Parameters
valvalue object
Returns
double value

◆ zclk_val_get_flag()

MODULE_API int zclk_val_get_flag ( zclk_val val)

get the flag value

Parameters
valvalue object
Returns
flag value

◆ zclk_val_get_int()

MODULE_API int zclk_val_get_int ( zclk_val val)

get the int value

Parameters
valvalue object
Returns
int value

◆ zclk_val_get_string()

MODULE_API const char* zclk_val_get_string ( zclk_val val)

get the string value

Parameters
valvalue object
Returns
string value

◆ zclk_val_set_bool()

MODULE_API void zclk_val_set_bool ( zclk_val val,
int  bval 
)

set the boolean value

Parameters
valvalue object
bvalboolean value

◆ zclk_val_set_dobule()

MODULE_API void zclk_val_set_dobule ( zclk_val val,
double  dval 
)

set the double value

Parameters
valvalue object
bvaldouble value

◆ zclk_val_set_flag()

MODULE_API void zclk_val_set_flag ( zclk_val val,
int  fval 
)

set the flag value

Parameters
valvalue object
bvalflag value

◆ zclk_val_set_int()

MODULE_API void zclk_val_set_int ( zclk_val val,
int  ival 
)

set the int value

Parameters
valvalue object
bvalint value

◆ zclk_val_set_string()

MODULE_API void zclk_val_set_string ( zclk_val val,
const char *  sval 
)

set the string value

Parameters
valvalue object
bvalstring value