From 37352aa7e19e0bfebbd0c32985cbf79a83508538 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 7 Feb 2021 20:44:56 +0100 Subject: [PATCH] Support --no-net for backwards compatibility --- src/libutil/args.cc | 3 +++ src/libutil/args.hh | 1 + src/nix/main.cc | 1 + 3 files changed, 5 insertions(+) diff --git a/src/libutil/args.cc b/src/libutil/args.cc index 71bae0504..9377fe4c0 100644 --- a/src/libutil/args.cc +++ b/src/libutil/args.cc @@ -14,6 +14,8 @@ void Args::addFlag(Flag && flag_) assert(flag->handler.arity == flag->labels.size()); assert(flag->longName != ""); longFlags[flag->longName] = flag; + for (auto & alias : flag->aliases) + longFlags[alias] = flag; if (flag->shortName) shortFlags[flag->shortName] = flag; } @@ -191,6 +193,7 @@ nlohmann::json Args::toJSON() for (auto & [name, flag] : longFlags) { auto j = nlohmann::json::object(); + if (flag->aliases.count(name)) continue; if (flag->shortName) j["shortName"] = std::string(1, flag->shortName); if (flag->description != "") diff --git a/src/libutil/args.hh b/src/libutil/args.hh index 42d8515ef..88f068087 100644 --- a/src/libutil/args.hh +++ b/src/libutil/args.hh @@ -97,6 +97,7 @@ protected: typedef std::shared_ptr ptr; std::string longName; + std::set aliases; char shortName = 0; std::string description; std::string category; diff --git a/src/nix/main.cc b/src/nix/main.cc index e95b04d85..ef5e41a55 100644 --- a/src/nix/main.cc +++ b/src/nix/main.cc @@ -92,6 +92,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs addFlag({ .longName = "offline", + .aliases = {"no-net"}, // FIXME: remove .description = "Disable substituters and consider all previously downloaded files up-to-date.", .handler = {[&]() { useNet = false; }}, });