aboutsummaryrefslogtreecommitdiff
path: root/src/libmain/shared.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-01-08 12:51:19 +0100
committerEelco Dolstra <edolstra@gmail.com>2021-01-08 12:51:19 +0100
commit17beae299d5e6bb511c453d0b9d0d7ef906b3d14 (patch)
tree318c9a3745c9778dc47b92af67229d8fb2287805 /src/libmain/shared.cc
parent6548b89cc4eb214cb4632fd4332c610f2d1f0a9d (diff)
Support binary unit prefixes in command line arguments
Diffstat (limited to 'src/libmain/shared.cc')
-rw-r--r--src/libmain/shared.cc6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index f1feeddd6..e797c2fb9 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -219,10 +219,8 @@ LegacyArgs::LegacyArgs(const std::string & programName,
.description = description,
.labels = {"n"},
.handler = {[=](std::string s) {
- if (auto n = string2Int<unsigned int>(s))
- settings.set(dest, std::to_string(*n));
- else
- throw UsageError("'%s' is not an integer", s);
+ auto n = string2IntWithUnitPrefix<uint64_t>(s);
+ settings.set(dest, std::to_string(n));
}}
});
};