mirror of
https://github.com/NixOS/nix.git
synced 2025-11-14 22:42:41 +01:00
Merge remote-tracking branch 'upstream/master' into list-experimental-features
This commit is contained in:
commit
3f98353f19
29 changed files with 241 additions and 84 deletions
|
|
@ -236,8 +236,6 @@ nlohmann::json Args::toJSON()
|
|||
auto flags = nlohmann::json::object();
|
||||
|
||||
for (auto & [name, flag] : longFlags) {
|
||||
/* Skip experimental flags when listing flags. */
|
||||
if (!experimentalFeatureSettings.isEnabled(flag->experimentalFeature)) continue;
|
||||
auto j = nlohmann::json::object();
|
||||
if (flag->aliases.count(name)) continue;
|
||||
if (flag->shortName)
|
||||
|
|
@ -249,6 +247,11 @@ nlohmann::json Args::toJSON()
|
|||
j["arity"] = flag->handler.arity;
|
||||
if (!flag->labels.empty())
|
||||
j["labels"] = flag->labels;
|
||||
// TODO With C++23 use `std::optional::tranform`
|
||||
if (auto & xp = flag->experimentalFeature)
|
||||
j["experimental-feature"] = showExperimentalFeature(*xp);
|
||||
else
|
||||
j["experimental-feature"] = nullptr;
|
||||
flags[name] = std::move(j);
|
||||
}
|
||||
|
||||
|
|
@ -345,6 +348,11 @@ Strings argvToStrings(int argc, char * * argv)
|
|||
return args;
|
||||
}
|
||||
|
||||
std::optional<ExperimentalFeature> Command::experimentalFeature ()
|
||||
{
|
||||
return { Xp::NixCommand };
|
||||
}
|
||||
|
||||
MultiCommand::MultiCommand(const Commands & commands_)
|
||||
: commands(commands_)
|
||||
{
|
||||
|
|
@ -408,6 +416,11 @@ nlohmann::json MultiCommand::toJSON()
|
|||
cat["id"] = command->category();
|
||||
cat["description"] = trim(categories[command->category()]);
|
||||
j["category"] = std::move(cat);
|
||||
// TODO With C++23 use `std::optional::tranform`
|
||||
if (auto xp = command->experimentalFeature())
|
||||
cat["experimental-feature"] = showExperimentalFeature(*xp);
|
||||
else
|
||||
cat["experimental-feature"] = nullptr;
|
||||
cmds[name] = std::move(j);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -236,6 +236,8 @@ struct Command : virtual public Args
|
|||
|
||||
static constexpr Category catDefault = 0;
|
||||
|
||||
virtual std::optional<ExperimentalFeature> experimentalFeature ();
|
||||
|
||||
virtual Category category() { return catDefault; }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -65,9 +65,10 @@ public:
|
|||
switch (lvl) {
|
||||
case lvlError: c = '3'; break;
|
||||
case lvlWarn: c = '4'; break;
|
||||
case lvlInfo: c = '5'; break;
|
||||
case lvlNotice: case lvlInfo: c = '5'; break;
|
||||
case lvlTalkative: case lvlChatty: c = '6'; break;
|
||||
default: c = '7';
|
||||
case lvlDebug: case lvlVomit: c = '7';
|
||||
default: c = '7'; break; // should not happen, and missing enum case is reported by -Werror=switch-enum
|
||||
}
|
||||
prefix = std::string("<") + c + ">";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue