cmd: add functions to report option/arg errors to the public API
This commit is contained in:
@@ -19,6 +19,13 @@ enum cmd_string_flags {
|
||||
CMD_STR_DIRECT_USAGE = 0x02u,
|
||||
};
|
||||
|
||||
enum b_command_usage_entry_type {
|
||||
CMD_USAGE_NONE = 0,
|
||||
CMD_USAGE_ARG,
|
||||
CMD_USAGE_OPT,
|
||||
CMD_USAGE_COMMAND,
|
||||
};
|
||||
|
||||
struct b_string;
|
||||
|
||||
struct b_command {
|
||||
@@ -41,28 +48,22 @@ struct b_command {
|
||||
struct b_btree_node b_node;
|
||||
};
|
||||
|
||||
struct b_command_usage_opt {
|
||||
struct b_queue_entry opt_entry;
|
||||
struct b_command_option *opt;
|
||||
};
|
||||
struct b_command_usage_entry {
|
||||
struct b_queue_entry e_entry;
|
||||
enum b_command_usage_entry_type e_type;
|
||||
|
||||
struct b_command_usage_arg {
|
||||
struct b_queue_entry arg_entry;
|
||||
struct b_command_arg *arg;
|
||||
};
|
||||
|
||||
struct b_command_usage_command {
|
||||
struct b_queue_entry cmd_entry;
|
||||
unsigned int cmd_id;
|
||||
union {
|
||||
struct b_command_option *e_opt;
|
||||
struct b_command_arg *e_arg;
|
||||
unsigned int e_cmd_id;
|
||||
};
|
||||
};
|
||||
|
||||
struct b_command_usage {
|
||||
b_command_usage_flags u_flags;
|
||||
struct b_queue_entry u_entry;
|
||||
|
||||
struct b_queue u_cmd;
|
||||
struct b_queue u_opt;
|
||||
struct b_queue u_arg;
|
||||
struct b_queue u_parts;
|
||||
};
|
||||
|
||||
struct b_command_option {
|
||||
@@ -97,6 +98,7 @@ struct b_arglist_option {
|
||||
};
|
||||
|
||||
struct b_arglist {
|
||||
struct b_command *list_command;
|
||||
struct b_btree list_options;
|
||||
};
|
||||
|
||||
@@ -111,6 +113,13 @@ BLUE_API struct b_command_option *b_command_get_option_with_long_name(
|
||||
struct b_command *cmd, const char *long_name);
|
||||
BLUE_API struct b_command_option *b_command_get_option_with_short_name(
|
||||
struct b_command *cmd, char short_name);
|
||||
BLUE_API struct b_command_option *b_command_get_option_with_id(
|
||||
struct b_command *cmd, unsigned int id);
|
||||
BLUE_API struct b_command_arg *b_command_get_arg_with_id(
|
||||
struct b_command *cmd, unsigned int id);
|
||||
|
||||
BLUE_API struct b_command_arg *b_command_option_get_arg_with_id(
|
||||
struct b_command_option *opt, unsigned int id);
|
||||
|
||||
BLUE_API struct b_command_option *b_command_option_create(void);
|
||||
BLUE_API void b_command_option_destroy(struct b_command_option *opt);
|
||||
|
||||
Reference in New Issue
Block a user