cmd: add support for dynamically generating command options at runtime
This commit is contained in:
@@ -61,6 +61,12 @@
|
||||
this_opt = opt_##id; \
|
||||
if (this_opt)
|
||||
|
||||
#define B_COMMAND_OPTION_GEN(id) \
|
||||
b_command_option *z__b_unique_name() \
|
||||
= b_command_add_option(this_cmd, (id)); \
|
||||
this_opt = z__b_unique_name(); \
|
||||
if (this_opt)
|
||||
|
||||
#define B_COMMAND_HELP_OPTION() \
|
||||
do { \
|
||||
b_command_option *opt \
|
||||
@@ -210,6 +216,11 @@ BLUE_API b_command_option *b_command_add_option(b_command *cmd, int id);
|
||||
BLUE_API b_command_arg *b_command_add_arg(b_command *cmd, int id);
|
||||
BLUE_API b_command_usage *b_command_add_usage(b_command *cmd);
|
||||
|
||||
BLUE_API const b_command_option *b_command_get_option(const b_command *cmd, int id);
|
||||
|
||||
BLUE_API const char *b_command_option_get_long_name(const b_command_option *opt);
|
||||
BLUE_API char b_command_option_get_short_name(const b_command_option *opt);
|
||||
BLUE_API const char *b_command_option_get_description(b_command_option *opt);
|
||||
BLUE_API b_status b_command_option_set_long_name(
|
||||
b_command_option *opt, const char *name);
|
||||
BLUE_API b_status b_command_option_set_short_name(b_command_option *opt, char name);
|
||||
|
||||
Reference in New Issue
Block a user