Skip to content

Commit

Permalink
fix: split the CLI args to ensure version is used at the binary level
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm committed Nov 19, 2024
1 parent cda0b9a commit d835965
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bin/torii/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ base64.workspace = true
camino.workspace = true
chrono.workspace = true
clap.workspace = true
clap_complete.workspace = true
ctrlc = { version = "3.4", features = [ "termination" ] }
dojo-metrics.workspace = true
dojo-types.workspace = true
Expand Down
14 changes: 14 additions & 0 deletions bin/torii/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! CLI for Torii.
//!
//! Use a `Cli` struct to parse the CLI arguments
//! and to have flexibility in the future to add more commands
//! that may not start Torii directly.
use clap::Parser;
use torii_cli::ToriiArgs;

#[derive(Parser)]
#[command(name = "torii", author, version, about, long_about = None)]
pub struct Cli {
#[command(flatten)]
pub args: ToriiArgs,
}
7 changes: 4 additions & 3 deletions bin/torii/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::time::Duration;

use camino::Utf8PathBuf;
use clap::Parser;
use cli::Cli;
use dojo_metrics::exporters::prometheus::PrometheusRecorder;
use dojo_world::contracts::world::WorldContractReader;
use sqlx::sqlite::{
Expand All @@ -30,7 +31,6 @@ use tempfile::{NamedTempFile, TempDir};
use tokio::sync::broadcast;
use tokio::sync::broadcast::Sender;
use tokio_stream::StreamExt;
use torii_cli::ToriiArgs;
use torii_core::engine::{Engine, EngineConfig, IndexingFlags, Processors};
use torii_core::executor::Executor;
use torii_core::processors::store_transaction::StoreTransactionProcessor;
Expand All @@ -46,17 +46,18 @@ use url::{form_urlencoded, Url};

pub(crate) const LOG_TARGET: &str = "torii::cli";

mod cli;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let mut args = ToriiArgs::parse().with_config_file()?;
let mut args = Cli::parse().args.with_config_file()?;

let world_address = if let Some(world_address) = args.world_address {
world_address
} else {
return Err(anyhow::anyhow!("Please specify a world address."));
};

// let mut contracts = parse_erc_contracts(&args.contracts)?;
args.indexing.contracts.push(Contract { address: world_address, r#type: ContractType::WORLD });

let filter_layer = EnvFilter::try_from_default_env()
Expand Down

0 comments on commit d835965

Please sign in to comment.