-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
68 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use clap::Parser; | ||
use anyhow::Result; | ||
use clap::Args; | ||
|
||
#[derive(Parser)] | ||
pub struct Deposit { | ||
#[clap(flatten)] | ||
deposit_args: DepositArgs | ||
} | ||
|
||
impl Deposit { | ||
pub async fn execute(self) -> Result<()> { | ||
let DepositArgs { | ||
token, | ||
amount, | ||
vault_id, | ||
} = &self.deposit_args; | ||
println!("Token: {}, Amount: {}, Vault ID: {}", token, amount, vault_id); | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[derive(Args)] | ||
pub struct DepositArgs { | ||
#[arg(short, long, help = "The token address in hex format")] | ||
token: String, | ||
|
||
#[arg(short, long, help = "The amount to deposit")] | ||
amount: u64, | ||
|
||
#[arg(short, long, help = "The ID of the vault")] | ||
vault_id: u64, | ||
} |
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,4 @@ | ||
mod order; | ||
mod deposit; | ||
|
||
pub use self::{order::*, deposit::*}; |
11 changes: 6 additions & 5 deletions
11
crates/cli/src/orderbook/order/mod.rs → crates/cli/src/commands/order.rs
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,22 @@ | ||
use anyhow::Result; | ||
use clap::Subcommand; | ||
|
||
use crate::commands::{Order, Deposit}; | ||
|
||
mod commands; | ||
|
||
#[derive(Subcommand)] | ||
pub enum Orderbook { | ||
#[command(subcommand)] | ||
Order(Order), | ||
Deposit(Deposit), | ||
} | ||
|
||
impl Orderbook { | ||
pub async fn execute(self) -> Result<()> { | ||
match self { | ||
Orderbook::Order(order) => order.execute().await, | ||
Orderbook::Deposit(deposit) => deposit.execute().await, | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,18 +1,17 @@ | ||
use clap::Parser; | ||
use anyhow::Result; | ||
|
||
mod orderbook; | ||
use rain_orderbook_cli::Orderbook; | ||
|
||
#[derive(Parser)] | ||
#[command(author, version, about, long_about = None)] | ||
struct Cli { | ||
#[command(subcommand)] | ||
orderbook: orderbook::Orderbook, | ||
orderbook: Orderbook, | ||
} | ||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
tracing::subscriber::set_global_default(tracing_subscriber::fmt::Subscriber::new())?; | ||
|
||
let cli = Cli::parse(); | ||
orderbook::dispatch(cli.orderbook).await | ||
cli.orderbook.execute().await | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.