}
Formatter *
-new_formatter(const std::string &type)
+new_formatter(const std::string type)
{
- if (type == "json")
+ std::string mytype = type;
+ if (mytype == "")
+ mytype = "json-pretty";
+
+ if (mytype == "json")
return new JSONFormatter(false);
- else if (type == "json-pretty")
+ else if (mytype == "json-pretty")
return new JSONFormatter(true);
- else if (type == "xml")
+ else if (mytype == "xml")
return new XMLFormatter(false);
- else if (type == "xml-pretty")
+ else if (mytype == "xml-pretty")
return new XMLFormatter(true);
else
return (Formatter *)NULL;
cmd_getval(m_cct, cmdmap, "format", format);
cmd_getval(m_cct, cmdmap, "prefix", c);
- // we don't do plain here
- if (format != "json" &&
- format != "json-pretty" &&
- format != "xml" &&
- format != "xml-pretty")
- format = "json";
-
string firstword;
if (c.find(" ") == string::npos)
firstword = c;
public:
HelpHook(AdminSocket *as) : m_as(as) {}
bool call(string command, string args, string format, bufferlist& out) {
- // override format here because help should always be pretty and
- // predictable
- Formatter *f = new_formatter("json-pretty");
+ Formatter *f = new_formatter(format);
f->open_object_section("help");
for (map<string,string>::iterator p = m_as->m_help.begin();
p != m_as->m_help.end();