diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2022-03-08 21:12:57 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2022-03-11 12:57:10 +0300 |
commit | 8c257da85cde2df8f459f0c7610445971fffb2a8 (patch) | |
tree | 5ff670a42257ac6e1374da3ec0055a9ea348d871 /libbuild2/types-parsers.cxx | |
parent | a061301ab789d00027f29f389627792dccbe1748 (diff) |
Add JSON format support for --structured-result option and info meta operation
Diffstat (limited to 'libbuild2/types-parsers.cxx')
-rw-r--r-- | libbuild2/types-parsers.cxx | 20 |
1 files changed, 18 insertions, 2 deletions
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 <libbuild2/types-parsers.hxx> -#include <libbuild2/b-options.hxx> // build2::build::cli namespace - namespace build2 { namespace build @@ -48,6 +46,24 @@ namespace build2 xs = true; parse_path (x, s); } + + void parser<structured_result_format>:: + 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); + } } } } |