diff --git a/src/cli.cpp b/src/cli.cpp index 6e19a0df..c2b2875e 100644 --- a/src/cli.cpp +++ b/src/cli.cpp @@ -85,14 +85,14 @@ void cli_tool_t::help() "(c) Vitaliy Filippov, 2019+ (VNPL-1.1)\n" "\n" "USAGE:\n" - "%s ls [-l] [--del] [-p ] [-w]\n" - " List images.\n" + "%s ls [-l] [-p POOL] [--sort FIELD] [-r] [-n N] [ ...]\n" + " List images (only specified if passed).\n" " -p|--pool POOL Filter images by pool ID or name\n" " -l|--long Also report allocated size and I/O statistics\n" " --del Also include delete operation statistics\n" - " --sort Sort by specified field (name, size, used_size, _)\n" + " --sort FIELD Sort by specified field (name, size, used_size, _)\n" " -r|--reverse Sort in descending order\n" - " --top Only list top items\n" + " -n|--count N Only list first N items\n" "\n" "%s create -s|--size [-p|--pool ] [--parent [@]] \n" " Create an image. You may use K/M/G/T suffixes for . If --parent is specified,\n" diff --git a/src/cli_ls.cpp b/src/cli_ls.cpp index 84775ab5..a72c0d0f 100644 --- a/src/cli_ls.cpp +++ b/src/cli_ls.cpp @@ -26,6 +26,7 @@ struct image_lister_t pool_id_t list_pool_id = 0; std::string list_pool_name; std::string sort_field; + std::set only_names; bool reverse = false; int max_count = 0; bool show_stats = false, show_delete = false; @@ -212,7 +213,10 @@ resume_1: json11::Json::array list; for (auto & kv: stats) { - list.push_back(kv.second); + if (!only_names.size() || only_names.find(kv.second["name"].string_value()) != only_names.end()) + { + list.push_back(kv.second); + } } if (sort_field == "name" || sort_field == "pool_name") { @@ -500,7 +504,11 @@ std::function cli_tool_t::start_ls(json11::Json cfg) lister->show_delete = cfg["del"].bool_value(); lister->sort_field = cfg["sort"].string_value(); lister->reverse = cfg["reverse"].bool_value(); - lister->max_count = cfg["top"].uint64_value(); + lister->max_count = cfg["count"].uint64_value(); + for (int i = 0; i < cmd.size(); i++) + { + lister->only_names.insert(cmd[i].string_value()); + } return [lister]() { lister->loop();