forked from vitalif/vitastor
Allow to disable colored output
parent
e4efa2c08a
commit
577a563b91
|
@ -52,7 +52,7 @@ json11::Json::object cli_tool_t::parse_args(int narg, const char *args[])
|
|||
{
|
||||
const char *opt = args[i]+2;
|
||||
cfg[opt] = i == narg-1 || !strcmp(opt, "json") || !strcmp(opt, "wait-list") ||
|
||||
!strcmp(opt, "long") || !strcmp(opt, "del") ||
|
||||
!strcmp(opt, "long") || !strcmp(opt, "del") || !strcmp(opt, "no-color") ||
|
||||
!strcmp(opt, "writers-stopped") && strcmp("1", args[i+1]) != 0
|
||||
? "1" : args[++i];
|
||||
}
|
||||
|
@ -127,6 +127,7 @@ void cli_tool_t::help()
|
|||
" --parallel_osds M Work with M osds in parallel when possible (default 4)\n"
|
||||
" --progress 1|0 Report progress (default 1)\n"
|
||||
" --cas 1|0 Use online CAS writes when possible (default auto)\n"
|
||||
" --no-color Disable colored output\n"
|
||||
" --json JSON output\n"
|
||||
,
|
||||
exe_name, exe_name, exe_name, exe_name, exe_name, exe_name, exe_name, exe_name, exe_name
|
||||
|
@ -258,6 +259,7 @@ void cli_tool_t::run(json11::Json cfg)
|
|||
fprintf(stderr, "unknown command: %s\n", cmd[0].string_value().c_str());
|
||||
exit(1);
|
||||
}
|
||||
color = !cfg["no-color"].bool_value();
|
||||
json_output = cfg["json"].bool_value();
|
||||
iodepth = cfg["iodepth"].uint64_value();
|
||||
if (!iodepth)
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
bool list_first = false;
|
||||
bool json_output = false;
|
||||
int log_level = 0;
|
||||
int mode = 0;
|
||||
bool color = false;
|
||||
|
||||
ring_loop_t *ringloop = NULL;
|
||||
epoll_manager_t *epmgr = NULL;
|
||||
|
|
|
@ -348,7 +348,7 @@ resume_1:
|
|||
kv.second["size_fmt"] = format_size(kv.second["size"].uint64_value());
|
||||
kv.second["ro"] = kv.second["readonly"].bool_value() ? "RO" : "-";
|
||||
}
|
||||
printf("%s", print_table(to_list(), cols, true).c_str());
|
||||
printf("%s", print_table(to_list(), cols, parent->color).c_str());
|
||||
state = 100;
|
||||
}
|
||||
};
|
||||
|
@ -393,7 +393,8 @@ std::string print_table(json11::Json items, json11::Json header, bool use_esc)
|
|||
}
|
||||
}
|
||||
if (use_esc)
|
||||
str += "\033[0m\n";
|
||||
str += "\033[0m";
|
||||
str += "\n";
|
||||
for (auto & item: items.array_items())
|
||||
{
|
||||
for (int i = 0; i < header.array_items().size(); i++)
|
||||
|
|
Loading…
Reference in New Issue