}
if (option_parsed) {
- if (! option.info->tagged) {
+ if (! (option.info->flags & VSC_CLI__OPTION_FLAG__TAGGED)) {
++untagged_option_index;
}
for (i = 0; command_info->option_infos[i].long_name != NULL; ++i) {
option_info = &command_info->option_infos[i];
- if (! option_info->required) {
+ if (! (option_info->flags & VSC_CLI__OPTION_FLAG__REQUIRED)) {
continue;
}
}
static char *
-_readline_options_generator(const char *text, int state)
+_readline_options_generator (const char *text, int state)
{
static int last_index, text_length;
static const struct VscCliCommandInfo *command_info = NULL;
option_info = &command_info->option_infos[last_index];
++last_index;
- if (! option_info->tagged) {
+ if (! (option_info->flags & VSC_CLI__OPTION_FLAG__TAGGED)) {
continue;
}
option_info = &command_info->option_infos[k];
if (option_info->type == VSC_CLI__OPTION_TYPE__BOOLEAN &&
- ! option_info->tagged) {
+ ! (option_info->flags & VSC_CLI__OPTION_FLAG__TAGGED)) {
VSC__ERROR1 (error, VSC__ERROR_CODE__INVALID_ARGUMENT,
"Boolean options can not untagged");
return;
} else {
fprintf (stream, "%s: %s\n",
_vsc_cli_output_coloring ? prefix_colored : prefix,
- vsc_error_string(error->code));
+ vsc_error_string (error->code));
}
}
}
static const struct VscCliOptionInfo _help_option_infos[] = {
{ -1, "command", "Name of command", VSC_CLI__OPTION_TYPE__STRING,
- FALSE, FALSE },
+ VSC_CLI__OPTION_FLAG__NONE },
VSC_CLI__NULL__OPTION_INFO,
};
option_info = &command_info_->option_infos[i];
syntax = _vsc_cli_option_syntax (option_info, TRUE);
- if (option_info->required) {
+ if (option_info->flags & VSC_CLI__OPTION_FLAG__REQUIRED) {
total = _limited_printf (indent, total, " %s", syntax);
} else {
total = _limited_printf (indent, total, " [%s]", syntax);
option_info = &_vsc_cli_option_infos[i];
syntax = _vsc_cli_option_syntax (option_info, TRUE);
- if (option_info->required) {
+ if (option_info->flags & VSC_CLI__OPTION_FLAG__REQUIRED) {
total = _limited_printf (" ", total, " %s", syntax);
} else {
total = _limited_printf (" ", total, " [%s]", syntax);
VSC__ASSERT (option_info != NULL);
- if (option_info->tagged) {
+ if (option_info->flags & VSC_CLI__OPTION_FLAG__TAGGED) {
if (option_info->type == VSC_CLI__OPTION_TYPE__BOOLEAN) {
if (synopsis) {
snprintf (syntax, 512, "--%s", option_info->long_name);
VSC__ASSERT (option_name != NULL);
for (i = 0; option_infos[i].long_name != NULL; i++) {
- if (! option_infos[i].tagged) {
+ if (! (option_infos[i].flags & VSC_CLI__OPTION_FLAG__TAGGED)) {
continue;
}
VSC__ASSERT (position >= 0);
for (i = 0; option_infos[i].long_name != NULL; i++) {
- if (! option_infos[i].tagged) {
+ if (! (option_infos[i].flags & VSC_CLI__OPTION_FLAG__TAGGED)) {
if (position > 0) {
--position;
} else {
#include "types.h"
-#define VSC_CLI__NULL__OPTION_INFO { -1, NULL, NULL, 0, FALSE, FALSE }
+#define VSC_CLI__NULL__OPTION_INFO \
+ { -1, NULL, NULL, VSC_CLI__OPTION_TYPE__UNDEFINED, \
+ VSC_CLI__OPTION_FLAG__NONE }
#define VSC_CLI__VERBOSE_ERRORS__OPTION_INFO__LONG_NAME "verbose-errors"
#define VSC_CLI__VERBOSE_ERRORS__OPTION_INFO \
{ -1, VSC_CLI__VERBOSE_ERRORS__OPTION_INFO__LONG_NAME, \
"Enable verbose error reporting", \
- VSC_CLI__OPTION_TYPE__BOOLEAN, TRUE, FALSE }
+ VSC_CLI__OPTION_TYPE__BOOLEAN, VSC_CLI__OPTION_FLAG__TAGGED }
#define VSC_CLI__NO_COLOR__OPTION_INFO__LONG_NAME "no-color"
#define VSC_CLI__NO_COLOR__OPTION_INFO \
{ -1, VSC_CLI__NO_COLOR__OPTION_INFO__LONG_NAME, \
"Disable output coloring", \
- VSC_CLI__OPTION_TYPE__BOOLEAN, TRUE, FALSE }
+ VSC_CLI__OPTION_TYPE__BOOLEAN, VSC_CLI__OPTION_FLAG__TAGGED }
#ifdef __cplusplus
extern "C" {
#endif
enum VscCliOptionType {
- VSC_CLI__OPTION_TYPE__BOOLEAN = 0,
+ VSC_CLI__OPTION_TYPE__UNDEFINED = 0,
+ VSC_CLI__OPTION_TYPE__BOOLEAN,
VSC_CLI__OPTION_TYPE__NUMBER,
VSC_CLI__OPTION_TYPE__STRING,
};
+enum VscCliOptionFlag {
+ VSC_CLI__OPTION_FLAG__NONE = 0,
+ VSC_CLI__OPTION_FLAG__TAGGED = 1,
+ VSC_CLI__OPTION_FLAG__REQUIRED = 2,
+};
+
struct VscCliOption;
struct VscCliCommandInfo;
const char* long_name;
const char* help;
enum VscCliOptionType type;
- int tagged;
- int required;
+ int flags;
};
struct VscCliOption {
static const struct VscCliOptionInfo _login_option_infos[] = {
{ -1, "username", "Username for the remote system",
- VSC_CLI__OPTION_TYPE__STRING, FALSE, TRUE },
+ VSC_CLI__OPTION_TYPE__STRING, VSC_CLI__OPTION_FLAG__REQUIRED },
{ -1, "password", "Password for the remote system",
- VSC_CLI__OPTION_TYPE__STRING, FALSE, FALSE },
+ VSC_CLI__OPTION_TYPE__STRING, VSC_CLI__OPTION_FLAG__NONE },
VSC_CLI__NULL__OPTION_INFO,
};
goto cleanup;
}
} else if (option_info->type == VSC_CLI__OPTION_TYPE__BOOLEAN &&
- option_info->required) {
+ option_info->flags & VSC_CLI__OPTION_FLAG__REQUIRED) {
value = xmlrpc_bool_new (&env, FALSE);
} else {
continue;