summaryrefslogtreecommitdiff
path: root/src/common.cc
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-05-07 02:18:07 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-05-07 02:18:07 +0300
commit7e743b73433475df086fcec81be7b10c1d695a42 (patch)
tree1737c5f9bdad2a40f740e9a655e510641331b9e2 /src/common.cc
initial
Diffstat (limited to 'src/common.cc')
-rw-r--r--src/common.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/common.cc b/src/common.cc
new file mode 100644
index 0000000..fbd1614
--- /dev/null
+++ b/src/common.cc
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: BSD-3-Clause
+
+#include "common.h"
+#include <stdexcept>
+
+formatter::Format format_from_string(std::string& s) {
+ if (s == "json")
+ return formatter::Format::JSON;
+ else if (s == "table")
+ return formatter::Format::Table;
+ else if (s == "simple-table")
+ return formatter::Format::SimpleTable;
+ else
+ throw std::invalid_argument("invalid format");
+} \ No newline at end of file