From 6340b54d5c39d1ef5647c79a98d219cc5d8228d2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 6 Jan 2012 22:26:21 +0100 Subject: options: allow choice options without parameter If an m_option_type_choice option is declared with M_OPT_IMPLICIT_DEFAULT in its flags, it doesn't require a parameter. For example, if --opt is such an option, it can be invoked as "--opt=val", "-opt", or "--opt". The last two will set the option to the first choice the option declares. Note that "-opt val" (using the old option syntax) is not allowed in this case, as it would be ambiguous. Normal option parsing should be unaffected. --- m_option.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'm_option.h') diff --git a/m_option.h b/m_option.h index 5b7e051290..10c832d76c 100644 --- a/m_option.h +++ b/m_option.h @@ -338,6 +338,11 @@ struct m_option { // The option should be set during command line pre-parsing #define M_OPT_PRE_PARSE (1 << 6) +// Accept an option without parameter, even if the option type normally requires +// a parameter. The option value will be set to a default value. +// For m_option_type_choice, the first listed choice will be used. +#define M_OPT_IMPLICIT_DEFAULT (1 << 7) + // These are kept for compatibility with older code. #define CONF_MIN M_OPT_MIN #define CONF_MAX M_OPT_MAX -- cgit v1.2.3