about summary refs log tree commit diff
path: root/src/libutil/args.hh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-09-06T14·20+0200
committerEelco Dolstra <edolstra@gmail.com>2017-09-06T14·20+0200
commitdff440aab32131b3459cadc2c4cc60c6f42674c6 (patch)
treea8a0634eb1e9766857cd1c2429809349421e495c /src/libutil/args.hh
parentdf4342bc175a153986ebcf5bce2a758d5353adeb (diff)
nix build: Add --out-link and --no-link options
Diffstat (limited to 'src/libutil/args.hh')
-rw-r--r--src/libutil/args.hh13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libutil/args.hh b/src/libutil/args.hh
index 044ed209e3bf..7f8ea647c909 100644
--- a/src/libutil/args.hh
+++ b/src/libutil/args.hh
@@ -80,6 +80,19 @@ public:
         FlagMaker & arity(size_t arity) { flag->arity = arity; return *this; };
         FlagMaker & handler(std::function<void(Strings)> handler) { flag->handler = handler; return *this; };
         FlagMaker & category(const std::string & s) { flag->category = s; return *this; };
+
+        FlagMaker & dest(std::string * dest) {
+            assert(flag->arity == 1);
+            flag->handler = [=](Strings ss) { *dest = ss.front(); };
+            return *this;
+        };
+
+        template<class T>
+        FlagMaker & set(T * dest, const T & val) {
+            assert(flag->arity == 0);
+            flag->handler = [=](Strings ss) { *dest = val; };
+            return *this;
+        };
     };
 
     FlagMaker mkFlag();