Skip to content

Commit 63402b2

Browse files
committed
build: Introduce cargo-make configuration
1 parent bb293ff commit 63402b2

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

Makefile.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[config]
2+
default_to_workspace = false
3+
skip_core_tasks = true
4+
5+
[env.RUST_LOG]
6+
value = "warn"
7+
8+
[env.RUST_LOG.condition]
9+
env_not_set = ["RUST_LOG"]
10+
11+
[env.PROFILE]
12+
source = "${CARGO_MAKE_PROFILE}"
13+
default_value = "localnet"
14+
15+
[env.PROFILE.mapping]
16+
development = "localnet"
17+
production = "mainnet"
18+
localnet = "localnet"
19+
devnet = "devnet"
20+
testnet = "testnet"
21+
mainnet = "mainnet"
22+
23+
[tasks.interceptor]
24+
cwd = "./metabased-sequencer/"
25+
command = "cargo"
26+
toolchain = "nightly"
27+
args = ["run", "-p", "interceptor", "--", "--profile", "${PROFILE}"]

metabased-sequencer/interceptor/src/presentation/cli.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use clap::{Parser, ValueEnum};
44
use figment::providers::{Env, Serialized};
55
use figment::Figment;
66
use serde::{Deserialize, Serialize};
7+
use tracing::log;
78
use tracing_subscriber::EnvFilter;
89
use url::Url;
910

@@ -38,12 +39,14 @@ fn parse_args() -> anyhow::Result<Args> {
3839

3940
let _ = dotenv::dotenv();
4041

41-
if let Some(profile) = args.profile {
42-
dotenv::from_filename(match profile {
43-
Profile::Mainnet => "mainnet.env",
44-
Profile::Testnet => "testnet.env",
45-
Profile::Devnet => "devnet.env",
46-
})?;
42+
if let Some(env_file) = args.profile.map(|profile| match profile {
43+
Profile::Mainnet => "mainnet.env",
44+
Profile::Testnet => "testnet.env",
45+
Profile::Devnet => "devnet.env",
46+
Profile::Localnet => "localnet.env",
47+
}) {
48+
let _ = dotenv::from_filename(env_file)
49+
.inspect_err(|e| log::warn!("Cannot open {env_file}: {e}"));
4750
}
4851

4952
let args = Figment::new()
@@ -65,6 +68,7 @@ enum Profile {
6568
Mainnet,
6669
Testnet,
6770
Devnet,
71+
Localnet,
6872
}
6973

7074
#[derive(Parser, Debug, Serialize, Deserialize)]

0 commit comments

Comments
 (0)