ZClk
0.1.0-alpha.3
Library to build cli programs
|
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"
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_val * | new_zclk_val_bool (int bool_val) |
Create a new boolean value. More... | |
MODULE_API zclk_val * | new_zclk_val_int (int int_val) |
Create a new int value. More... | |
MODULE_API zclk_val * | new_zclk_val_double (double double_val) |
Create a new double value. More... | |
MODULE_API zclk_val * | new_zclk_val_string (const char *string_val) |
Create a new string value. More... | |
MODULE_API zclk_val * | new_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_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 More... | |
MODULE_API zclk_option * | new_zclk_option_bool (const char *name, const char *short_name, int default_val, const char *desc) |
MODULE_API zclk_option * | new_zclk_option_int (const char *name, const char *short_name, int default_val, const char *desc) |
MODULE_API zclk_option * | new_zclk_option_double (const char *name, const char *short_name, double default_val, const char *desc) |
MODULE_API zclk_option * | new_zclk_option_string (const char *name, const char *short_name, const char *default_val, const char *desc) |
MODULE_API zclk_option * | new_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_option * | get_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_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 More... | |
MODULE_API zclk_argument * | new_zclk_argument_bool (const char *name, int default_val, const char *desc, int nargs) |
MODULE_API zclk_argument * | new_zclk_argument_int (const char *name, int default_val, const char *desc, int nargs) |
MODULE_API zclk_argument * | new_zclk_argument_double (const char *name, double default_val, const char *desc, int nargs) |
MODULE_API zclk_argument * | new_zclk_argument_string (const char *name, const char *default_val, const char *desc, int nargs) |
MODULE_API zclk_argument * | new_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_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. 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_option * | zclk_command_get_option (zclk_command *cmd, const char *name) |
Get the option object corresponding to given name. More... | |
MODULE_API zclk_argument * | zclk_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... | |
Zclk main header file. Defines the Public API of zclk.
#define zclk_boolean | ( | v | ) | new_zclk_val_bool(v) |
Create a new boolean cli value.
v | value |
#define zclk_command_argument_foreach | ( | cmd, | |
arg | |||
) |
Iterator for arguments of the given command.
cmd | command object |
arg | name of the argument which will contain an argument in every iteration. |
#define zclk_command_option_foreach | ( | cmd, | |
opt | |||
) |
Iterator for options of the given command.
cmd | command object |
opt | name of the argument which will contain an option in every iteration. |
#define zclk_double | ( | v | ) | new_zclk_val_double(v) |
Create a new double cli value.
v | value |
#define zclk_flag | ( | v | ) | new_zclk_val_flag(v) |
Create a new flag cli value.
v | value |
#define zclk_int | ( | v | ) | new_zclk_val_int(v) |
Create a new integer cli value.
v | value |
#define ZCLK_OPTION_HELP_DESC "Print help for command." |
Help option description
#define ZCLK_OPTION_HELP_LONG "help" |
Help option long name
#define ZCLK_OPTION_HELP_SHORT "h" |
Help option short name
#define zclk_string | ( | v | ) | new_zclk_val_string(v) |
Create a new string cli value.
v | value |
#define zclk_val_is_bool | ( | val | ) | zclk_val_is_type(val, ZCLK_TYPE_BOOLEAN) |
Check if given value is boolean.
val | value object |
#define zclk_val_is_double | ( | val | ) | zclk_val_is_type(val, ZCLK_TYPE_DOUBLE) |
Check if given value is double.
val | value object |
#define zclk_val_is_flag | ( | val | ) | zclk_val_is_type(val, ZCLK_TYPE_FLAG) |
Check if given value is flag.
val | value object |
#define zclk_val_is_int | ( | val | ) | zclk_val_is_type(val, ZCLK_TYPE_INT) |
Check if given value is int.
val | value object |
#define zclk_val_is_string | ( | val | ) | zclk_val_is_type(val, ZCLK_TYPE_STRING) |
Check if given value is string.
val | value object |
MODULE_API void clear_zclk_val | ( | zclk_val * | val | ) |
Reset values to system defaults.
Copy values from 'from' to 'to'. Can be used to reset to defaults.
to | val to set |
from | val to read from |
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
commands | the list of commands registered (this is a list of zclk_command*) |
handler_args | an args value to be passed to the command handler |
argc | the number of tokens in the line |
argv | args as an array of strings |
MODULE_API void free_argument | ( | zclk_argument * | arg | ) |
Free resources used by argument
MODULE_API void free_command | ( | zclk_command * | command | ) |
Free a command object
command | command object to free |
MODULE_API void free_option | ( | zclk_option * | option | ) |
Free resources used by option
option | to free |
MODULE_API void free_zclk_val | ( | zclk_val * | val | ) |
Free the created value
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.
help_str | the help string to return |
commands | is the configured list of commands |
arg_commands | is a list of string |
MODULE_API char* get_help_for_command | ( | arraylist * | cmds_to_exec | ) |
Get help for a command
cmds_to_exec | the list of commands and subcommands parsed |
MODULE_API zclk_option* get_option_by_name | ( | arraylist * | options, |
const char * | name | ||
) |
Get the option by name object.
options | options list |
name | name of option to retrieve |
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
commands | the list of commands registered (this is a list of zclk_command*) |
handler_args | an args value to be passed to the command handler |
argc | the number of tokens in the line |
argv | args as an array of strings |
success_handler | handle success results |
error_handler | handler error results |
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.
arg | object to create |
name | |
val | |
default_val | |
desc |
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.
command | obj to be created |
name | |
short_name | |
description | |
handler | function ptr to handler |
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.
option | object to create |
name | |
short_name | |
val | |
default_val | |
description |
Create a new value object of given type.
val | object to create |
type |
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.
name | |
val | |
default_val | |
desc | |
nargs |
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.
name | |
short_name | |
description | |
handler |
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.
name | name of the option |
short_name | short name |
val | value object |
default_val | default value object |
desc | description |
MODULE_API zclk_val* new_zclk_val_bool | ( | int | bool_val | ) |
Create a new boolean value.
bool_val | value |
MODULE_API zclk_val* new_zclk_val_double | ( | double | double_val | ) |
Create a new double value.
double_val | value |
MODULE_API zclk_val* new_zclk_val_flag | ( | int | flag_val | ) |
Create a new flag value.
flag_val | value |
MODULE_API zclk_val* new_zclk_val_int | ( | int | int_val | ) |
Create a new int value.
int_val | value |
MODULE_API zclk_val* new_zclk_val_string | ( | const char * | string_val | ) |
Create a new string value.
string_val | value |
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
val | object whose value will be set |
input | string input |
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.
result_flag | error flag |
res_type | result type |
result | result object |
MODULE_API void print_table_result | ( | void * | result | ) |
Print a tabular result object to the stdout.
result | table result object |
MODULE_API zclk_res zclk_command_argument_add | ( | zclk_command * | cmd, |
zclk_argument * | arg | ||
) |
Add an argument to the given command.
cmd | command |
arg | argument to add |
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.
cmd | command object |
name | name of the argument |
default_val | default value |
desc | text description |
nargs | number of occurences (-1 means unlimited occurences) |
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.
cmd | command object |
name | name of the option |
short_name | short name of the option |
desc | text description |
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.
cmd | command object |
name | name of the argument |
default_val | default value |
desc | text description |
nargs | number of occurences (-1 means unlimited occurences) |
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.
cmd | command object |
name | name of the option |
short_name | short name of the option |
default_val | default value |
desc | text description |
MODULE_API zclk_res zclk_command_exec | ( | zclk_command * | cmd, |
void * | exec_args, | ||
int | argc, | ||
char * | argv[] | ||
) |
Execute the command with the given args.
cmd | Command to execute |
exec_args | exec args |
argc | arg count |
argv | arg values |
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.
cmd | command object |
name | name of the argument |
default_val | default value |
desc | text description |
nargs | number of occurences (-1 means unlimited occurences) |
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.
cmd | command object |
name | name of the option |
short_name | short name of the option |
desc | text description |
MODULE_API zclk_argument* zclk_command_get_argument | ( | zclk_command * | cmd, |
const char * | name | ||
) |
Get the argument object corresponding to given name.
cmd | command object |
name | name of the argument |
MODULE_API zclk_option* zclk_command_get_option | ( | zclk_command * | cmd, |
const char * | name | ||
) |
Get the option object corresponding to given name.
cmd | command object |
name | name of the option |
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.
cmd | command object |
name | name of the argument |
default_val | default value |
desc | text description |
nargs | number of occurences (-1 means unlimited occurences) |
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.
cmd | command object |
name | name of the option |
short_name | short name of the option |
default_val | default value |
desc | text description |
MODULE_API zclk_res zclk_command_option_add | ( | zclk_command * | cmd, |
zclk_option * | option | ||
) |
Add an option to the given command.
cmd | command |
option | option to add |
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.
cmd | command object |
name | name of the argument |
default_val | default value |
desc | text description |
nargs | number of occurences (-1 means unlimited occurences) |
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.
cmd | command object |
name | name of the option |
short_name | short name of the option |
default_val | default value |
desc | text description |
MODULE_API zclk_res zclk_command_subcommand_add | ( | zclk_command * | cmd, |
zclk_command * | subcommand | ||
) |
Add a subcommand to the given command.
cmd | command |
subcommand | subcommand to add |
MODULE_API void zclk_fill_options_in_list | ( | arraylist * | optlist, |
zclk_option * | options[] | ||
) |
Fill the entries in the given option array into an arraylist.
optlist | arraylist to fill |
options | options array to use |
MODULE_API int zclk_val_get_bool | ( | zclk_val * | val | ) |
get the boolean value
val | value object |
MODULE_API double zclk_val_get_double | ( | zclk_val * | val | ) |
get the double value
val | value object |
MODULE_API int zclk_val_get_flag | ( | zclk_val * | val | ) |
get the flag value
val | value object |
MODULE_API int zclk_val_get_int | ( | zclk_val * | val | ) |
get the int value
val | value object |
MODULE_API const char* zclk_val_get_string | ( | zclk_val * | val | ) |
get the string value
val | value object |
MODULE_API void zclk_val_set_bool | ( | zclk_val * | val, |
int | bval | ||
) |
set the boolean value
val | value object |
bval | boolean value |
MODULE_API void zclk_val_set_dobule | ( | zclk_val * | val, |
double | dval | ||
) |
set the double value
val | value object |
bval | double value |
MODULE_API void zclk_val_set_flag | ( | zclk_val * | val, |
int | fval | ||
) |
set the flag value
val | value object |
bval | flag value |
MODULE_API void zclk_val_set_int | ( | zclk_val * | val, |
int | ival | ||
) |
set the int value
val | value object |
bval | int value |
MODULE_API void zclk_val_set_string | ( | zclk_val * | val, |
const char * | sval | ||
) |
set the string value
val | value object |
bval | string value |