message: cleos system listbw
diff: @@ -1112,6 +1112,43 @@ struct undelegate_bandwidth_subcommand {
  }
  };
  +struct list_bw_subcommand {
  + eosio::name account;
  + bool print_json = false;
  +
  + list_bw_subcommand(CLI::App* actionRoot) {
  + auto list_bw = actionRoot->add_subcommand("listbw", localized("List delegated bandwidth"));
  + list_bw->add_option("account", account, localized("The account delegated bandwidth"))->required();
  + list_bw->add_flag("--json,-j", print_json, localized("Output in JSON format") );
  +
  + list_bw->set_callback([this] {
  + //get entire table in scope of user account
  + auto result = call(get_table_func, fc::mutable_variant_object("json", true)
  + ("code", name(config::system_account_name).to_string())
  + ("scope", account.to_string())
  + ("table", "delband")
  + );
  + if (!print_json) {
  + auto res = result.as<eosio::chain_apis::read_only::get_table_rows_result>();
  + if ( !res.rows.empty() ) {
  + std::cout << std::setw(13) << std::left << "Receiver" << std::setw(21) << std::left << "Net bandwidth"
  + << std::setw(21) << std::left << "Net bandwidth" << std::endl;
  + for ( auto& r : res.rows ){
  + std::cout << std::setw(13) << std::left << r["to"].as_string()
  + << std::setw(21) << std::left << r["net_weight"].as_string()
  + << std::setw(21) << std::left << r["net_weight"].as_string()
  + << std::endl;
  + }
  + } else {
  + std::cerr << "Delegated bandwidth not found" << std::endl;
  + }
  + } else {
  + std::cout << fc::json::to_pretty_string(result) << std::endl;
  + }
  + });
  + }
  +};
  +
  struct buyram_subcommand {
  string from_str;
  string receiver_str;
  @@ -2426,6 +2463,7 @@ int main( int argc, char** argv ) {
  auto delegateBandWidth = delegate_bandwidth_subcommand(system);
  auto undelegateBandWidth = undelegate_bandwidth_subcommand(system);
  + auto listBandWidth = list_bw_subcommand(system);
  auto biyram = buyram_subcommand(system);
  auto sellram = sellram_subcommand(system);
  