-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from darthsiroftardis/get-era-summary
Add `get-era-summary` subcommand - Manual Merge as can't disable in flight 18.04 requirement for testing.
- Loading branch information
Showing
7 changed files
with
163 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use std::str; | ||
|
||
use async_trait::async_trait; | ||
use clap::{App, ArgMatches, SubCommand}; | ||
|
||
use casper_client::{Error, GetEraSummary}; | ||
|
||
use crate::{command::ClientCommand, common, Success}; | ||
|
||
enum DisplayOrder { | ||
Verbose, | ||
NodeAddress, | ||
RpcId, | ||
BlockIdentifier, | ||
} | ||
|
||
#[async_trait] | ||
impl<'a, 'b> ClientCommand<'a, 'b> for GetEraSummary { | ||
const NAME: &'static str = "get-era-summary"; | ||
const ABOUT: &'static str = "Retrieves era information from the network"; | ||
|
||
fn build(display_order: usize) -> App<'a, 'b> { | ||
SubCommand::with_name(Self::NAME) | ||
.about(Self::ABOUT) | ||
.display_order(display_order) | ||
.arg(common::verbose::arg(DisplayOrder::Verbose as usize)) | ||
.arg(common::node_address::arg( | ||
DisplayOrder::NodeAddress as usize, | ||
)) | ||
.arg(common::rpc_id::arg(DisplayOrder::RpcId as usize)) | ||
.arg(common::block_identifier::arg( | ||
DisplayOrder::BlockIdentifier as usize, | ||
)) | ||
} | ||
|
||
async fn run(matches: &ArgMatches<'a>) -> Result<Success, Error> { | ||
let maybe_rpc_id = common::rpc_id::get(matches); | ||
let node_address = common::node_address::get(matches); | ||
let verbosity_level = common::verbose::get(matches); | ||
let maybe_block_id = common::block_identifier::get(matches); | ||
|
||
casper_client::get_era_summary(maybe_rpc_id, node_address, verbosity_level, maybe_block_id) | ||
.await | ||
.map(Success::from) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters