Skip to content

Commit a18fde4

Browse files
authored
Merge pull request #125 from HerodotusDev/cli-fix
fix: cli env to be compatible with legacy
2 parents 36913aa + 7fb17d3 commit a18fde4

File tree

6 files changed

+26
-20
lines changed

6 files changed

+26
-20
lines changed

Diff for: cli/src/cli.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use hdp::{
2020
TaskEnvelope,
2121
},
2222
};
23-
use tracing::info;
23+
use tracing::{debug, info};
2424
use tracing_subscriber::{EnvFilter, FmtSubscriber};
2525

2626
pub async fn hdp_cli_run() -> anyhow::Result<()> {
@@ -53,7 +53,7 @@ fn init_cli() -> Result<HDPCli> {
5353
.with_env_filter(EnvFilter::new(&rust_log))
5454
.finish();
5555
tracing::subscriber::set_global_default(subscriber).expect("Failed to set subscriber");
56-
info!("running on log level: {}", rust_log);
56+
debug!("running on log level: {}", rust_log);
5757
let cli = HDPCli::parse();
5858
Ok(cli)
5959
}
@@ -62,7 +62,7 @@ pub async fn module_entry_run(args: RunModuleArgs) -> Result<()> {
6262
let config = hdp_run::HdpRunConfig::init(
6363
args.rpc_url,
6464
args.chain_id,
65-
Some(args.dry_run_cairo_file),
65+
args.dry_run_cairo_file,
6666
args.sound_run_cairo_file,
6767
args.preprocessor_output_file,
6868
args.save_fetch_keys_file,

Diff for: cli/src/commands/run.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct RunArgs {
2121

2222
/// Path to save output file after pre-processing.
2323
#[arg(short, long)]
24-
pub preprocessor_output_file: PathBuf,
24+
pub preprocessor_output_file: Option<PathBuf>,
2525

2626
/// hdp cairo compiled program. main entry point
2727
#[arg(long)]

Diff for: cli/src/commands/run_datalake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub struct RunDatalakeArgs {
3333
///
3434
/// This will trigger pre-processing step
3535
#[arg(short, long)]
36-
pub preprocessor_output_file: PathBuf,
36+
pub preprocessor_output_file: Option<PathBuf>,
3737

3838
/// hdp cairo compiled program. main entry point
3939
#[arg(long)]

Diff for: cli/src/commands/run_module.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ pub struct RunModuleArgs {
4545
/// dry run contract bootloader program.
4646
/// only used for module task
4747
#[arg(long)]
48-
pub dry_run_cairo_file: PathBuf,
48+
pub dry_run_cairo_file: Option<PathBuf>,
4949

5050
/// Path to save output file after pre-processing.
5151
///
5252
/// This will trigger pre-processing step
5353
#[arg(short, long)]
54-
pub preprocessor_output_file: PathBuf,
54+
pub preprocessor_output_file: Option<PathBuf>,
5555

5656
/// hdp cairo compiled program. main entry point
5757
#[arg(long)]

Diff for: cli/src/interactive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ pub async fn run_interactive() -> anyhow::Result<()> {
365365
chain_id,
366366
None,
367367
None,
368-
cairo_input,
368+
Some(cairo_input),
369369
None,
370370
Some(output_file),
371371
Some(pie_file),

Diff for: hdp/src/hdp_run.rs

+18-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
use alloy::primitives::ChainId;
2-
use anyhow::Result;
3-
use reqwest::Url;
4-
use std::{env, fs, path::PathBuf};
5-
use tracing::{debug, info};
6-
7-
#[cfg(feature = "test_utils")]
8-
use crate::constant::DEFAULT_PREPROCESSOR_OUTPUT_FILE;
9-
101
use crate::{
11-
constant::{DEFAULT_DRY_CAIRO_RUN_CAIRO_FILE, DEFAULT_SOUND_CAIRO_RUN_CAIRO_FILE},
2+
constant::{
3+
DEFAULT_DRY_CAIRO_RUN_CAIRO_FILE, DEFAULT_PREPROCESSOR_OUTPUT_FILE,
4+
DEFAULT_SOUND_CAIRO_RUN_CAIRO_FILE,
5+
},
126
preprocessor::{compile::config::CompilerConfig, PreProcessor},
137
primitives::{processed_types::cairo_format::AsCairoFormat, task::TaskEnvelope},
148
processor::Processor,
159
provider::evm::config::EvmProviderConfig,
1610
};
11+
use alloy::primitives::ChainId;
12+
use anyhow::Result;
13+
use reqwest::Url;
14+
use std::{env, fs, path::PathBuf};
15+
use tracing::{debug, info};
1716

1817
/// HdpRunConfig for the CLI
1918
#[derive(Debug)]
@@ -48,7 +47,7 @@ impl HdpRunConfig {
4847
cli_chain_id: Option<ChainId>,
4948
cli_dry_run_cairo_file: Option<PathBuf>,
5049
cli_sound_run_cairo_file: Option<PathBuf>,
51-
cli_pre_processor_output_file: PathBuf,
50+
cli_pre_processor_output_file: Option<PathBuf>,
5251
cli_save_fetch_keys_file: Option<PathBuf>,
5352
cli_processor_output_file: Option<PathBuf>,
5453
cli_cairo_pie_file: Option<PathBuf>,
@@ -71,6 +70,13 @@ impl HdpRunConfig {
7170
.expect("RPC_CHUNK_SIZE must be a number");
7271
let save_fetch_keys_file: Option<PathBuf> = cli_save_fetch_keys_file
7372
.or_else(|| env::var("SAVE_FETCH_KEYS_FILE").ok().map(PathBuf::from));
73+
let pre_processor_output_file: PathBuf =
74+
cli_pre_processor_output_file.unwrap_or_else(|| {
75+
env::var("DRY_RUN_CAIRO_PATH")
76+
.unwrap_or_else(|_| DEFAULT_PREPROCESSOR_OUTPUT_FILE.to_string())
77+
.parse()
78+
.expect("DRY_RUN_CAIRO_PATH must be a path to a cairo file")
79+
});
7480
let dry_run_cairo_path: PathBuf = cli_dry_run_cairo_file.unwrap_or_else(|| {
7581
env::var("DRY_RUN_CAIRO_PATH")
7682
.unwrap_or_else(|_| DEFAULT_DRY_CAIRO_RUN_CAIRO_FILE.to_string())
@@ -92,7 +98,7 @@ impl HdpRunConfig {
9298
},
9399
dry_run_program_path: dry_run_cairo_path,
94100
sound_run_program_path: sound_run_cairo_path,
95-
pre_processor_output_file: cli_pre_processor_output_file,
101+
pre_processor_output_file,
96102
save_fetch_keys_file,
97103
processor_output_file: cli_processor_output_file,
98104
cairo_pie_file: cli_cairo_pie_file,

0 commit comments

Comments
 (0)