forked from lix-project/lix
Bail if plugin-files is set after plugins have been loaded.
We know the flag will be ignored but the user wants it to take effect.
This commit is contained in:
parent
a878c448d8
commit
ec3497c1d6
|
@ -243,6 +243,14 @@ void MaxBuildJobsSetting::set(const std::string & str, bool append)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PluginFilesSetting::set(const std::string & str, bool append)
|
||||||
|
{
|
||||||
|
if (pluginsLoaded)
|
||||||
|
throw UsageError("plugin-files set after plugins were loaded, you may need to move the flag before the subcommand");
|
||||||
|
BaseSetting<Paths>::set(str, append);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void initPlugins()
|
void initPlugins()
|
||||||
{
|
{
|
||||||
for (const auto & pluginFile : settings.pluginFiles.get()) {
|
for (const auto & pluginFile : settings.pluginFiles.get()) {
|
||||||
|
@ -270,6 +278,9 @@ void initPlugins()
|
||||||
unknown settings. */
|
unknown settings. */
|
||||||
globalConfig.reapplyUnknownSettings();
|
globalConfig.reapplyUnknownSettings();
|
||||||
globalConfig.warnUnknownSettings();
|
globalConfig.warnUnknownSettings();
|
||||||
|
|
||||||
|
/* Tell the user if they try to set plugin-files after we've already loaded */
|
||||||
|
settings.pluginFiles.pluginsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,23 @@ struct MaxBuildJobsSetting : public BaseSetting<unsigned int>
|
||||||
void set(const std::string & str, bool append = false) override;
|
void set(const std::string & str, bool append = false) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PluginFilesSetting : public BaseSetting<Paths>
|
||||||
|
{
|
||||||
|
bool pluginsLoaded = false;
|
||||||
|
|
||||||
|
PluginFilesSetting(Config * options,
|
||||||
|
const Paths & def,
|
||||||
|
const std::string & name,
|
||||||
|
const std::string & description,
|
||||||
|
const std::set<std::string> & aliases = {})
|
||||||
|
: BaseSetting<Paths>(def, name, description, aliases)
|
||||||
|
{
|
||||||
|
options->addSetting(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set(const std::string & str, bool append = false) override;
|
||||||
|
};
|
||||||
|
|
||||||
class Settings : public Config {
|
class Settings : public Config {
|
||||||
|
|
||||||
unsigned int getDefaultCores();
|
unsigned int getDefaultCores();
|
||||||
|
@ -819,7 +836,7 @@ public:
|
||||||
Setting<uint64_t> minFreeCheckInterval{this, 5, "min-free-check-interval",
|
Setting<uint64_t> minFreeCheckInterval{this, 5, "min-free-check-interval",
|
||||||
"Number of seconds between checking free disk space."};
|
"Number of seconds between checking free disk space."};
|
||||||
|
|
||||||
Setting<Paths> pluginFiles{
|
PluginFilesSetting pluginFiles{
|
||||||
this, {}, "plugin-files",
|
this, {}, "plugin-files",
|
||||||
R"(
|
R"(
|
||||||
A list of plugin files to be loaded by Nix. Each of these files will
|
A list of plugin files to be loaded by Nix. Each of these files will
|
||||||
|
|
Loading…
Reference in a new issue