summaryrefslogtreecommitdiffstats
path: root/core/m_option.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-09-21 09:22:25 +0200
committerwm4 <wm4@nowhere>2013-02-09 00:21:17 +0100
commit267a889cc2c5ca688a2b8fc93cf8e5349a3c8a44 (patch)
treeee2561f256db05092e61fa797be4b7ecaf3db991 /core/m_option.h
parent5412993724aee1126bfc8dfbc0422ebe5251b9b6 (diff)
downloadmpv-267a889cc2c5ca688a2b8fc93cf8e5349a3c8a44.tar.bz2
mpv-267a889cc2c5ca688a2b8fc93cf8e5349a3c8a44.tar.xz
options: unify single dash and double dash options
There were two option syntax variations: "old": -opt value "new": --opt=value "-opt=value" was invalid, and "--opt value" meant "--opt=" followed by a separate option "value" (i.e. interpreted as filename). There isn't really any reason to do this. The "old" syntax used to be ambiguous (you had to call the option parser to know whether the following argument is an option value or a new option), but that has been removed. Further, using "=" in the option string is always unambiguous. Since the distinction between the two option variants is confusing, just remove the difference and allow "--opt value" and "-opt=value". To make this easier, do some other cleanups as well (e.g. avoid having to do a manual lookup of the option just to check for M_OPT_PRE_PARSE, which somehow ended up with finally getting rid of the m_config.mode member). Error reporting is still a mess, and we opt for reporting too many rather than too few errors to the user. There shouldn't be many user-visible changes. The --framedrop and --term-osd options now always require parameters. The --mute option is intentionally made ambiguous: it works like a flag option, but a value can be passed to it explicitly ("--mute=auto"). If the interpretation of the option is ambiguous (like "--mute auto"), the second string is interpreted as separate option or filename. (Normal flag options are actually ambiguous in this way too.)
Diffstat (limited to 'core/m_option.h')
-rw-r--r--core/m_option.h23
1 files changed, 16 insertions, 7 deletions
diff --git a/core/m_option.h b/core/m_option.h
index a3da08ea7a..e63bf3610f 100644
--- a/core/m_option.h
+++ b/core/m_option.h
@@ -363,6 +363,9 @@ struct m_option {
// (e.g. "--parent=child=value" becomes "--child=value")
#define M_OPT_MERGE (1 << 9)
+// See M_OPT_TYPE_OPTIONAL_PARAM.
+#define M_OPT_OPTIONAL_PARAM (1 << 10)
+
// These are kept for compatibility with older code.
#define CONF_MIN M_OPT_MIN
#define CONF_MAX M_OPT_MAX
@@ -397,10 +400,11 @@ struct m_option {
*/
#define M_OPT_TYPE_DYNAMIC (1 << 2)
-// The parameter is optional and by default no parameter is preferred. If the
-// "old syntax" is used, the command line parser will assume that the argument
-// takes no parameter.
-#define M_OPT_TYPE_OLD_SYNTAX_NO_PARAM (1 << 3)
+// The parameter is optional and by default no parameter is preferred. If
+// ambiguous syntax is used ("--opt value"), the command line parser will
+// assume that the argument takes no parameter. In config files, these
+// options can be used without "=" and value.
+#define M_OPT_TYPE_OPTIONAL_PARAM (1 << 3)
// modify M_OPT_TYPE_HAS_CHILD so that m_option::p points to
// struct m_sub_options, instead of a direct m_option array.
@@ -408,7 +412,9 @@ struct m_option {
///////////////////////////// Parser flags /////////////////////////////////
-// On success parsers return the number of arguments consumed: 0 or 1.
+// OptionParserReturn
+//
+// On success parsers return a number >= 0.
//
// To indicate that MPlayer should exit without playing anything,
// parsers return M_OPT_EXIT minus the number of parameters they
@@ -429,13 +435,16 @@ struct m_option {
// vary from type to type.
#define M_OPT_OUT_OF_RANGE -4
+// The option doesn't take a parameter.
+#define M_OPT_DISALLOW_PARAM -5
+
// Returned if the parser failed for any other reason than a bad parameter.
-#define M_OPT_PARSER_ERR -5
+#define M_OPT_PARSER_ERR -6
// Returned when MPlayer should exit. Used by various help stuff.
/** M_OPT_EXIT must be the lowest number on this list.
*/
-#define M_OPT_EXIT -6
+#define M_OPT_EXIT -7
char *m_option_strerror(int code);