Skip to content

Commit

Permalink
[runtimes] separate runtimes for diem_node and cli (0LNetworkCommunit…
Browse files Browse the repository at this point in the history
…y#203)

Co-authored-by: zoz <[email protected]>
Co-authored-by: 0o-de-lally <[email protected]>
Co-authored-by: Kalvis Kuskis <[email protected]>
Co-authored-by: Ubuntu <[email protected]>
  • Loading branch information
5 people committed Aug 16, 2024
1 parent 8aef681 commit ee64d9c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 26 deletions.
69 changes: 44 additions & 25 deletions tools/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,55 @@ enum Sub {
Wallet(WalletCli),
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
fn main() -> anyhow::Result<()> {
let cli = LibraCli::parse();
match cli.command {
Some(Sub::Config(config_cli)) => {
config_cli.run().await?;
}
Some(Sub::Move(move_tool)) => {
move_tool
.execute()
.await
.map_err(|e| anyhow!("Failed to execute move tool, message: {}", &e))?;
}
Some(Sub::Node(n)) => {
n.run().await?;
}
Some(Sub::Query(query_cli)) => {
query_cli.run().await?;
}
Some(Sub::Tower(tower_cli)) => {
tower_cli.run().await?;
}
Some(Sub::Txs(txs_cli)) => {
txs_cli.run().await?;
}
Some(Sub::Wallet(wallet_cli)) => {
wallet_cli.run().await?;
n.run()?;
}
_ => {
println!("\nliving is easy with eyes closed")
let rt = tokio::runtime::Runtime::new()?;
rt.block_on(async {
match cli.command {
Some(Sub::Config(config_cli)) => {
if let Err(e) = config_cli.run().await {
eprintln!("Failed to execute config tool, message: {}", &e);
}
}
Some(Sub::Move(move_tool)) => {
if let Err(e) = move_tool
.execute()
.await
.map_err(|e| anyhow!("Failed to execute move tool, message: {}", &e))
{
eprintln!("Failed to execute move tool, message: {}", &e);
}
}
Some(Sub::Query(query_cli)) => {
if let Err(e) = query_cli.run().await {
eprintln!("Failed to execute query tool, message: {}", &e);
}
}
Some(Sub::Tower(tower_cli)) => {
if let Err(e) = tower_cli.run().await {
eprintln!("Failed to execute tower tool, message: {}", &e);
}
}
Some(Sub::Txs(txs_cli)) => {
if let Err(e) = txs_cli.run().await {
eprintln!("Failed to execute txs tool, message: {}", &e);
}
}
Some(Sub::Wallet(wallet_cli)) => {
if let Err(e) = wallet_cli.run().await {
eprintln!("Failed to execute wallet tool, message: {}", &e);
}
}
_ => {
println!("\nliving is easy with eyes closed")
}
}
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion tools/cli/src/node_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct NodeCli {
}

impl NodeCli {
pub async fn run(&self) -> anyhow::Result<()> {
pub fn run(&self) -> anyhow::Result<()> {
// validators typically aren't looking for verbose logs.
// but they can set it if they wish with RUST_LOG=info
if std::env::var("RUST_LOG").is_err() {
Expand Down

0 comments on commit ee64d9c

Please sign in to comment.