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

Public Member Functions

 list_bw_subcommand (CLI::App *actionRoot)
 

Public Attributes

string account
 
bool print_json = false
 

Detailed Description

Definition at line 1652 of file main.cpp.

Constructor & Destructor Documentation

◆ list_bw_subcommand()

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

Definition at line 1656 of file main.cpp.

1656 {
1657 auto list_bw = actionRoot->add_subcommand("listbw", localized("List delegated bandwidth"));
1658 list_bw->add_option("account", account, localized("The account delegated bandwidth"))->required();
1659 list_bw->add_flag("--json,-j", print_json, localized("Output in JSON format") );
1660
1661 list_bw->callback([this] {
1662 //get entire table in scope of user account
1663 auto result = call(get_table_func, fc::mutable_variant_object("json", true)
1664 ("code", name(config::system_account_name).to_string())
1665 ("scope", name(account).to_string())
1666 ("table", "delband")
1667 );
1668 if (!print_json) {
1670 if ( !res.rows.empty() ) {
1671 std::cout << std::setw(13) << std::left << "Receiver" << std::setw(21) << std::left << "Net bandwidth"
1672 << std::setw(21) << std::left << "CPU bandwidth" << std::endl;
1673 for ( auto& r : res.rows ){
1674 std::cout << std::setw(13) << std::left << r["to"].as_string()
1675 << std::setw(21) << std::left << r["net_weight"].as_string()
1676 << std::setw(21) << std::left << r["cpu_weight"].as_string()
1677 << std::endl;
1678 }
1679 } else {
1680 std::cerr << "Delegated bandwidth not found" << std::endl;
1681 }
1682 } else {
1683 std::cout << fc::json::to_pretty_string(result) << std::endl;
1684 }
1685 });
1686 }
const mie::Vuint & r
Definition bn.cpp:28
std::string name
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
Option * add_option(std::string option_name, callback_t option_callback, std::string option_description="", bool defaulted=false, std::function< std::string()> func={})
Definition CLI11.hpp:5099
CRTP * required(bool value=true)
Set the option as required.
Definition CLI11.hpp:3400
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
fc::string to_string(double)
Definition string.cpp:131
const string get_table_func
Definition httpc.hpp:94
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

◆ account

string list_bw_subcommand::account

Definition at line 1653 of file main.cpp.

◆ print_json

bool list_bw_subcommand::print_json = false

Definition at line 1654 of file main.cpp.


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