From 8c257da85cde2df8f459f0c7610445971fffb2a8 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 8 Mar 2022 21:12:57 +0300 Subject: Add JSON format support for --structured-result option and info meta operation --- libbuild2/types-parsers.cxx | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'libbuild2/types-parsers.cxx') diff --git a/libbuild2/types-parsers.cxx b/libbuild2/types-parsers.cxx index 86ce219..7b4a65d 100644 --- a/libbuild2/types-parsers.cxx +++ b/libbuild2/types-parsers.cxx @@ -3,8 +3,6 @@ #include -#include // build2::build::cli namespace - namespace build2 { namespace build @@ -48,6 +46,24 @@ namespace build2 xs = true; parse_path (x, s); } + + void parser:: + parse (structured_result_format& x, bool& xs, scanner& s) + { + xs = true; + const char* o (s.next ()); + + if (!s.more ()) + throw missing_value (o); + + const string v (s.next ()); + if (v == "lines") + x = structured_result_format::lines; + else if (v == "json") + x = structured_result_format::json; + else + throw invalid_value (o, v); + } } } } -- cgit v1.1