Skip to content

Commit

Permalink
refactor(cli): merge argument parsing and command execution
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperFluffy committed Sep 26, 2024
1 parent 2da3a48 commit f90d3e3
Show file tree
Hide file tree
Showing 25 changed files with 1,142 additions and 1,136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use tracing::{
};

#[derive(Args, Debug)]
pub(crate) struct WithdrawalEvents {
pub(crate) struct WithdrawalEventsArgs {
/// The websocket endpoint of a geth compatible rollup.
#[arg(long)]
rollup_endpoint: String,
Expand Down Expand Up @@ -88,7 +88,7 @@ pub(crate) struct WithdrawalEvents {
force: bool,
}

impl WithdrawalEvents {
impl WithdrawalEventsArgs {
pub(crate) async fn run(self) -> eyre::Result<()> {
let Self {
rollup_endpoint,
Expand Down
33 changes: 33 additions & 0 deletions crates/astria-cli/src/bridge/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
pub(crate) mod collect;
pub(crate) mod submit;

use clap::Subcommand;
use color_eyre::eyre;

/// Interact with a Sequencer node
#[expect(
clippy::large_enum_variant,
reason = "these are fire-and-forget types that are instantiated once and consumed, so
that their size does not matter"
)]
#[derive(Debug, clap::Args)]
pub(super) struct Args {
#[command(subcommand)]
command: Command,
}

impl Args {
pub(super) async fn run(self) -> eyre::Result<()> {
match self.command {
Command::CollectWithdrawals(args) => args.run().await,
Command::SubmitWithdrawals(args) => args.run().await,
}
}
}

#[derive(Debug, Subcommand)]
enum Command {
/// Commands for interacting with Sequencer accounts
CollectWithdrawals(collect::WithdrawalEventsArgs),
SubmitWithdrawals(submit::WithdrawalEventsArgs),
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use tracing::{
};

#[derive(Args, Debug)]
pub(crate) struct WithdrawalEvents {
pub(crate) struct WithdrawalEventsArgs {
#[arg(long, short)]
input: PathBuf,
#[arg(long)]
Expand All @@ -44,7 +44,7 @@ pub(crate) struct WithdrawalEvents {
sequencer_url: String,
}

impl WithdrawalEvents {
impl WithdrawalEventsArgs {
pub(crate) async fn run(self) -> eyre::Result<()> {
let signing_key = read_signing_key(&self.signing_key).wrap_err_with(|| {
format!(
Expand Down
22 changes: 0 additions & 22 deletions crates/astria-cli/src/cli/bridge.rs

This file was deleted.

46 changes: 0 additions & 46 deletions crates/astria-cli/src/cli/mod.rs

This file was deleted.

Loading

0 comments on commit f90d3e3

Please sign in to comment.