about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/args.cc4
-rw-r--r--src/libutil/args.hh2
2 files changed, 5 insertions, 1 deletions
diff --git a/src/libutil/args.cc b/src/libutil/args.cc
index 2b72079f2b47..d17a1e7a9abb 100644
--- a/src/libutil/args.cc
+++ b/src/libutil/args.cc
@@ -102,9 +102,11 @@ bool Args::processFlag(Strings::iterator & pos, Strings::iterator end)
         ++pos;
         Strings args;
         for (size_t n = 0 ; n < flag.arity; ++n) {
-            if (pos == end)
+            if (pos == end) {
+                if (flag.arity == ArityAny) break;
                 throw UsageError(format("flag '%1%' requires %2% argument(s)")
                     % name % flag.arity);
+            }
             args.push_back(*pos++);
         }
         flag.handler(args);
diff --git a/src/libutil/args.hh b/src/libutil/args.hh
index fd910b965ccc..044ed209e3bf 100644
--- a/src/libutil/args.hh
+++ b/src/libutil/args.hh
@@ -26,6 +26,8 @@ public:
 
 protected:
 
+    static const size_t ArityAny = std::numeric_limits<size_t>::max();
+
     /* Flags. */
     struct Flag
     {