Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
get_schedule_subcommand Struct Reference

Public Member Functions

void print (const char *name, const fc::variant &schedule)
 
 get_schedule_subcommand (CLI::App *actionRoot)
 

Public Attributes

bool print_json = false
 

Detailed Description

Definition at line 1421 of file main.cpp.

Constructor & Destructor Documentation

◆ get_schedule_subcommand()

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

Definition at line 1448 of file main.cpp.

1448 {
1449 auto get_schedule = actionRoot->add_subcommand("schedule", localized("Retrieve the producer schedule"));
1450 get_schedule->add_flag("--json,-j", print_json, localized("Output in JSON format"));
1451 get_schedule->callback([this] {
1453 if ( print_json ) {
1454 std::cout << fc::json::to_pretty_string(result) << std::endl;
1455 return;
1456 }
1457 print("active", result["active"]);
1458 print("pending", result["pending"]);
1459 print("proposed", result["proposed"]);
1460 });
1461 }
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
const string get_schedule_func
Definition httpc.hpp:104
fc::variant call(const std::string &url, const std::string &path, const T &v)
Definition main.cpp:258
void print(const char *name, const fc::variant &schedule)
Definition main.cpp:1424
Here is the call graph for this function:

Member Function Documentation

◆ print()

void get_schedule_subcommand::print ( const char * name,
const fc::variant & schedule )
inline

Definition at line 1424 of file main.cpp.

1424 {
1425 if (schedule.is_null()) {
1426 printf("%s schedule empty\n\n", name);
1427 return;
1428 }
1429 printf("%s schedule version %s\n", name, schedule["version"].as_string().c_str());
1430 printf(" %-13s %s\n", "Producer", "Producer Authority");
1431 printf(" %-13s %s\n", "=============", "==================");
1432 for( auto& row: schedule["producers"].get_array() ) {
1433 if( row.get_object().contains("block_signing_key") ) {
1434 // pre 2.0
1435 printf( " %-13s %s\n", row["producer_name"].as_string().c_str(), row["block_signing_key"].as_string().c_str() );
1436 } else {
1437 printf( " %-13s ", row["producer_name"].as_string().c_str() );
1438 auto a = row["authority"].as<block_signing_authority>();
1439 static_assert( std::is_same<decltype(a), std::variant<block_signing_authority_v0>>::value,
1440 "Updates maybe needed if block_signing_authority changes" );
1441 block_signing_authority_v0 auth = std::get<block_signing_authority_v0>(a);
1442 printf( "%s\n", fc::json::to_string( auth, fc::time_point::maximum() ).c_str() );
1443 }
1444 }
1445 printf("\n");
1446 }
static string to_string(const variant &v, const yield_function_t &yield, const output_formatting format=output_formatting::stringify_large_ints_and_doubles)
Definition json.cpp:674
static constexpr time_point maximum()
Definition time.hpp:46
LOGGING_API void printf(Category category, const char *format,...)
Definition Logging.cpp:30
std::variant< block_signing_authority_v0 > block_signing_authority
#define value
Definition pkcs11.h:157
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
Immutable except for fc::from_variant.
Definition name.hpp:43
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ print_json

bool get_schedule_subcommand::print_json = false

Definition at line 1422 of file main.cpp.


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