feature flags: add the notion of a default value for each flag

This commit is contained in:
David Adam 2021-04-07 22:41:25 +08:00
parent 053acf5c6b
commit 2e44076397
2 changed files with 12 additions and 4 deletions

View File

@ -6,15 +6,20 @@
#include "wcstringutil.h"
features_t::features_t() = default;
features_t::features_t() {
for (const metadata_t &md : metadata) {
this->set(md.flag, md.default_value);
}
}
/// The set of features applying to this instance.
features_t features_t::global_features;
const features_t::metadata_t features_t::metadata[features_t::flag_count] = {
{stderr_nocaret, L"stderr-nocaret", L"3.0", L"^ no longer redirects stderr"},
{qmark_noglob, L"qmark-noglob", L"3.0", L"? no longer globs"},
{string_replace_backslash, L"regex-easyesc", L"3.1", L"string replace -r needs fewer \\'s"},
{stderr_nocaret, L"stderr-nocaret", L"3.0", L"^ no longer redirects stderr", false},
{qmark_noglob, L"qmark-noglob", L"3.0", L"? no longer globs", false},
{string_replace_backslash, L"regex-easyesc", L"3.1", L"string replace -r needs fewer \\'s",
false},
};
const struct features_t::metadata_t *features_t::metadata_for(const wchar_t *name) {

View File

@ -57,6 +57,9 @@ class features_t {
/// User-presentable description of the feature flag.
const wchar_t *description;
/// Default flag value.
const bool default_value;
};
/// The metadata, indexed by flag.