Skip to content

Commit faa53e4

Browse files
committed
Add config options as CLI arguments
1 parent 258d7e5 commit faa53e4

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tuktuk-crank-turner/src/main.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ pub struct Cli {
4949
/// settings in the given file.
5050
#[clap(short = 'c', long, default_value = "~/.config/helium/cli/tuktuk-crank-turner/config.toml")]
5151
pub config: Option<path::PathBuf>,
52+
53+
/// RPC endpoint URL
54+
#[clap(short = 'u', long)]
55+
pub rpc_url: Option<String>,
56+
57+
/// Path to Solana keypair file
58+
#[clap(short = 'k', long)]
59+
pub key_path: Option<String>,
60+
61+
/// Minimum crank fee in lamports
62+
#[clap(short = 'm', long)]
63+
pub min_crank_fee: Option<u64>,
5264
}
5365

5466
impl Cli {
@@ -100,7 +112,19 @@ const PACKED_TX_CHANNEL_CAPACITY: usize = 32;
100112
impl Cli {
101113
pub async fn run(&self) -> Result<()> {
102114
register_custom_metrics();
103-
let settings = Settings::new(self.get_expanded_config_path().as_ref())?;
115+
let mut settings = Settings::new(self.get_expanded_config_path().as_ref())?;
116+
117+
// Apply CLI overrides
118+
if let Some(rpc_url) = &self.rpc_url {
119+
settings.rpc_url = rpc_url.clone();
120+
}
121+
if let Some(key_path) = &self.key_path {
122+
settings.key_path = key_path.clone();
123+
}
124+
if let Some(min_crank_fee) = self.min_crank_fee {
125+
settings.min_crank_fee = min_crank_fee;
126+
}
127+
104128
tracing_subscriber::registry()
105129
.with(tracing_subscriber::EnvFilter::new(&settings.log))
106130
.with(tracing_subscriber::fmt::layer().with_span_events(FmtSpan::CLOSE))

0 commit comments

Comments
 (0)