From b8a670bbcefdec0f1ed95319e227068048e232c8 Mon Sep 17 00:00:00 2001 From: Patrick MARIE Date: Wed, 24 Feb 2021 23:57:41 +0100 Subject: [PATCH] Set cassandra servers with args or env var. --- src/main.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 357b7e5..09e7e70 100644 --- a/src/main.rs +++ b/src/main.rs @@ -213,6 +213,14 @@ fn metric_list(session: &Session, glob: &str) -> Result<(), Error> { fn main() -> Result<(), Box> { let matches = App::new("bgutil-rs") .setting(AppSettings::SubcommandRequired) + .arg(Arg::with_name("contact-metadata") + .long("contact-metadata") + .env("CASSANDRA_CONTACT_METADATA") + .takes_value(true)) + .arg(Arg::with_name("contact-points") + .long("contact-points") + .env("CASSANDRA_CONTACT_POINTS") + .takes_value(true)) .subcommand(SubCommand::with_name("info") .about("Information about a metric") .arg(Arg::with_name("metric") @@ -283,8 +291,15 @@ fn main() -> Result<(), Box> { .long("clean-directories"))) .get_matches(); - let contact_points_metadata = "tag--cstars07--cassandra-cstars07.query.consul.preprod.crto.in"; - let contact_points_data = "tag--cstars04--cassandra-cstars04.query.consul.preprod.crto.in"; + let mut contact_points_metadata = "localhost"; + if matches.is_present("contact-metadata") { + contact_points_metadata = matches.value_of("contact-metadata").unwrap(); + } + + let mut contact_points_data = "localhost"; + if matches.is_present("contact-points") { + contact_points_data = matches.value_of("contact-points").unwrap(); + } let session = Session::new(&contact_points_metadata, &contact_points_data)?;