" authenticate as\n"
" --keyfile <path> file containing secret key for use with cephx\n"
" --shared <tag> take a shared (rather than exclusive) lock\n"
-" --format <output-format> output format (default: plain, json, xml)\n";
+" --format <output-format> output format (default: plain, json, xml)\n"
+" --pretty-format make json or xml output more readable\n";
}
static string feature_str(uint64_t feature)
};
static int get_outfmt(const char *output_format,
+ bool pretty,
boost::scoped_ptr<Formatter> *f)
{
if (!strcmp(output_format, "json")) {
- f->reset(new JSONFormatter(false));
+ f->reset(new JSONFormatter(pretty));
} else if (!strcmp(output_format, "xml")) {
- f->reset(new XMLFormatter(false));
+ f->reset(new XMLFormatter(pretty));
} else if (strcmp(output_format, "plain")) {
cerr << "rbd: unknown format '" << output_format << "'" << std::endl;
return -EINVAL;
*devpath = NULL, *lock_cookie = NULL, *lock_client = NULL,
*lock_tag = NULL, *output_format = "plain";
bool lflag = false;
+ int pretty_format = 0;
long long stripe_unit = 0, stripe_count = 0;
long long bench_io_size = 4096, bench_io_threads = 16, bench_bytes = 1 << 30;
output_format = strdup(val.c_str());
output_format_specified = true;
}
+ } else if (ceph_argparse_binary_flag(args, i, &pretty_format, NULL, "--pretty-format", (char*)NULL)) {
} else {
++i;
}
return EXIT_FAILURE;
}
+ if (pretty_format && !strcmp(output_format, "plain")) {
+ cerr << "rbd: --pretty-format only works when --format is json or xml"
+ << std::endl;
+ return EXIT_FAILURE;
+ }
+
boost::scoped_ptr<Formatter> formatter;
if (output_format_specified && opt_cmd != OPT_SHOWMAPPED &&
opt_cmd != OPT_INFO && opt_cmd != OPT_LIST && opt_cmd != OPT_SNAP_LIST &&
cerr << "rbd: command doesn't use output formatting"
<< std::endl;
return EXIT_FAILURE;
- } else if (get_outfmt(output_format, &formatter) < 0) {
+ } else if (get_outfmt(output_format, pretty_format, &formatter) < 0) {
return EXIT_FAILURE;
}