Skip to content

Commit 400acc5

Browse files
committed
m_option: add M_OPT_PRIVATE
Used to mark private options that shouldn't be exposed to the users.
1 parent 24500c5 commit 400acc5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

options/m_config_frontend.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,9 @@ static int handle_set_opt_flags(struct m_config *config,
400400
return M_OPT_INVALID;
401401

402402
// Check if this option isn't forbidden in the current mode
403-
if ((flags & M_SETOPT_FROM_CONFIG_FILE) && (optflags & M_OPT_NOCFG)) {
403+
if ((flags & M_SETOPT_FROM_CONFIG_FILE) &&
404+
(optflags & (M_OPT_NOCFG | M_OPT_PRIVATE)))
405+
{
404406
MP_ERR(config, "The %s option can't be used in a config file.\n",
405407
co->name);
406408
return M_OPT_INVALID;
@@ -841,6 +843,8 @@ void m_config_print_option_list(const struct m_config *config, const char *name)
841843
for (int i = 0; i < config->num_opts; i++) {
842844
struct m_config_option *co = &sorted[i];
843845
const struct m_option *opt = co->opt;
846+
if (opt->flags & M_OPT_PRIVATE)
847+
continue;
844848
if (strcmp(name, "*") != 0 && !strstr(co->name, name))
845849
continue;
846850
MP_INFO(config, " %s%-30s", prefix, co->name);

options/m_option.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,11 @@ char *format_file_size(int64_t size);
488488
// Like M_OPT_TYPE_OPTIONAL_PARAM.
489489
#define M_OPT_OPTIONAL_PARAM (UINT64_C(1) << 54)
490490

491-
static_assert(!(UPDATE_OPTS_MASK & M_OPT_OPTIONAL_PARAM), "");
491+
// Option is private: forbidden in config files and hidden from --help listing.
492+
// Can still be used as a property by builtin scripts.
493+
#define M_OPT_PRIVATE (UINT64_C(1) << 53)
494+
495+
static_assert(!(UPDATE_OPTS_MASK & M_OPT_PRIVATE), "");
492496

493497
// These flags are used to describe special parser capabilities or behavior.
494498

0 commit comments

Comments
 (0)