aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-02-26 14:55:54 +0100
committerEelco Dolstra <edolstra@gmail.com>2021-02-26 14:55:54 +0100
commit453c3a603f4e6fa3f8c706e73f9869bc7f76c640 (patch)
tree87d70db57d33a66cb8752a1fd6ee4ae57202c30e /src/libutil
parent20ea1de77d9210e145d5ebb1dccd34c856149b2c (diff)
nix flake update: Recreate the lock file
This is probably what most people expect it to do. Fixes #3781. There is a new command 'nix flake lock' that has the old behaviour of 'nix flake update', i.e. it just adds missing lock file entries unless overriden using --update-input.
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/args.cc8
-rw-r--r--src/libutil/args.hh2
2 files changed, 10 insertions, 0 deletions
diff --git a/src/libutil/args.cc b/src/libutil/args.cc
index 75eb19d28..afed0670f 100644
--- a/src/libutil/args.cc
+++ b/src/libutil/args.cc
@@ -19,6 +19,14 @@ void Args::addFlag(Flag && flag_)
if (flag->shortName) shortFlags[flag->shortName] = flag;
}
+void Args::removeFlag(const std::string & longName)
+{
+ auto flag = longFlags.find(longName);
+ assert(flag != longFlags.end());
+ if (flag->second->shortName) shortFlags.erase(flag->second->shortName);
+ longFlags.erase(flag);
+}
+
void Completions::add(std::string completion, std::string description)
{
assert(description.find('\n') == std::string::npos);
diff --git a/src/libutil/args.hh b/src/libutil/args.hh
index 4721c21df..c08ba8abd 100644
--- a/src/libutil/args.hh
+++ b/src/libutil/args.hh
@@ -140,6 +140,8 @@ public:
void addFlag(Flag && flag);
+ void removeFlag(const std::string & longName);
+
void expectArgs(ExpectedArg && arg)
{
expectedArgs.emplace_back(std::move(arg));