summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-12-26 00:23:42 +0100
committerCarl Hetherington <cth@carlh.net>2024-12-26 00:27:12 +0100
commit03c518e976a2a9a3a3017a4d3bc559cae5537ac1 (patch)
tree139c6e0fc29436e263619469380af39337b31c58 /src/lib
parent795a2dad51ebcbecae5fb437fa29dce22d97c8a7 (diff)
Avoid the need for a raw_convert to string.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/create_cli.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/lib/create_cli.cc b/src/lib/create_cli.cc
index a007fe078..cacb56ba6 100644
--- a/src/lib/create_cli.cc
+++ b/src/lib/create_cli.cc
@@ -88,6 +88,25 @@ argument_option (int& n, int argc, char* argv[], string short_name, string long_
}
+template <>
+void
+argument_option(int& n, int argc, char* argv[], string short_name, string long_name, bool* claimed, optional<string>* error, string* out)
+{
+ string const a = argv[n];
+ if (a != short_name && a != long_name) {
+ return;
+ }
+
+ if ((n + 1) >= argc) {
+ **error = fmt::format("{}: option {} requires an argument", argv[0], long_name);
+ return;
+ }
+
+ *out = string(argv[++n]);
+ *claimed = true;
+}
+
+
template <class T>
void
argument_option (