26 const jsont &arguments =
json[
"arguments"];
30 "array expected",
"'arguments'");
35 if(!argument.is_string())
38 "string expected",
"argument");
41 cmdline.
args.push_back(argument.value);
48 "array expected",
"'options'");
53 if(option_pair.second.is_string() || option_pair.second.is_number())
56 cmdline.
set(option_pair.first, option_pair.second.value);
58 else if(option_pair.second.is_boolean())
61 if(option_pair.second.is_true())
62 cmdline.
set(option_pair.first);
64 else if(option_pair.second.is_array())
69 if(element.is_string())
70 cmdline.
set(option_pair.first, element.value);
74 "string expected", option_pair.first);
81 "unrecognized commandline option format",
83 "Boolean, string, number, or string array expected");
90 if(cmdline.
isset(
"json-interface"))
101 "JSON object expected at top-level",
"command-line JSON input");
109 cmdline.
set(
"json-ui");
virtual bool isset(char option) const
virtual void set(const std::string &option, bool value=true)
Set option option to value, or true if the value is omitted.
Thrown when users pass incorrect command line arguments, for example passing no files to analysis or ...
std::string what() const override
A human readable description of what went wrong.
Class that provides messages with a built-in verbosity 'level'.
json_arrayt & to_json_array(jsont &json)
json_objectt & to_json_object(jsont &json)
static void get_json_options(const json_objectt &json, cmdlinet &cmdline)
Parse commandline options from json into cmdline.
void json_interface(cmdlinet &cmdline, message_handlert &message_handler)
Parses the JSON-formatted command line from stdin.
JSON Commandline Interface.
bool parse_json(std::istream &in, const std::string &filename, message_handlert &message_handler, jsont &dest)
static void json(json_objectT &result, const irep_idt &property_id, const property_infot &property_info)