Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
list_producers_subcommand Struct Reference
Collaboration diagram for list_producers_subcommand:

Public Member Functions

 list_producers_subcommand (CLI::App *actionRoot)
 

Public Attributes

bool print_json = false
 
uint32_t limit = 50
 
std::string lower
 

Detailed Description

Definition at line 1383 of file main.cpp.

Constructor & Destructor Documentation

◆ list_producers_subcommand()

list_producers_subcommand::list_producers_subcommand ( CLI::App * actionRoot)
inline

Definition at line 1388 of file main.cpp.

1388 {
1389 auto list_producers = actionRoot->add_subcommand("listproducers", localized("List producers"));
1390 list_producers->add_flag("--json,-j", print_json, localized("Output in JSON format"));
1391 list_producers->add_option("-l,--limit", limit, localized("The maximum number of rows to return"));
1392 list_producers->add_option("-L,--lower", lower, localized("Lower bound value of key, defaults to first"));
1393 list_producers->callback([this] {
1395 ("json", true)("lower_bound", lower)("limit", limit));
1396 if ( print_json ) {
1397 std::cout << fc::json::to_pretty_string(rawResult) << std::endl;
1398 return;
1399 }
1400 auto result = rawResult.as<sysio::chain_apis::read_only::get_producers_result>();
1401 if ( result.rows.empty() ) {
1402 std::cout << "No producers found" << std::endl;
1403 return;
1404 }
1405 auto weight = result.total_producer_vote_weight;
1406 if ( !weight )
1407 weight = 1;
1408 printf("%-13s %-57s %-59s %s\n", "Producer", "Producer key", "Url", "Scaled votes");
1409 for ( auto& row : result.rows )
1410 printf("%-13.13s %-57.57s %-59.59s %1.4f\n",
1411 row["owner"].as_string().c_str(),
1412 row["producer_key"].as_string().c_str(),
1413 clean_output( row["url"].as_string() ).c_str(),
1414 row["total_votes"].as_double() / weight);
1415 if ( !result.more.empty() )
1416 std::cout << "-L " << clean_output( result.more ) << " for more" << std::endl;
1417 });
1418 }
Option * add_flag(std::string flag_name)
Add a flag with no description or variable assignment.
Definition CLI11.hpp:5265
App * add_subcommand(std::string subcommand_name="", std::string subcommand_description="")
Add a subcommand. Inherits INHERITABLE and OptionDefaults, and help flag.
Definition CLI11.hpp:5538
static string to_pretty_string(const variant &v, const yield_function_t &yield, const output_formatting format=output_formatting::stringify_large_ints_and_doubles)
Definition json.cpp:775
An order-preserving dictionary of variants.
#define localized(str,...)
Definition localize.hpp:10
LOGGING_API void printf(Category category, const char *format,...)
Definition Logging.cpp:30
const string get_producers_func
Definition httpc.hpp:103
std::string clean_output(std::string str)
Definition main.cpp:161
fc::variant call(const std::string &url, const std::string &path, const T &v)
Definition main.cpp:258
Here is the call graph for this function:

Member Data Documentation

◆ limit

uint32_t list_producers_subcommand::limit = 50

Definition at line 1385 of file main.cpp.

◆ lower

std::string list_producers_subcommand::lower

Definition at line 1386 of file main.cpp.

◆ print_json

bool list_producers_subcommand::print_json = false

Definition at line 1384 of file main.cpp.


The documentation for this struct was generated from the following file: