From 03312b8176bfd197aeb693721b516c6a25a4611e Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Sat, 16 Dec 2017 08:18:16 -0500 Subject: [PATCH] Pass factoids as a separate arg --- ircbot/src/bin/factoids.rs | 6 ++++-- ircbot/src/config.rs | 6 ------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/ircbot/src/bin/factoids.rs b/ircbot/src/bin/factoids.rs index 1c8583a..6f7a321 100644 --- a/ircbot/src/bin/factoids.rs +++ b/ircbot/src/bin/factoids.rs @@ -10,13 +10,14 @@ extern crate env_logger; #[macro_use] extern crate log; +use ircbot::factoids::Factoids; use amqp::protocol::basic::Deliver; use amqp::protocol::basic::BasicProperties; use amqp::Basic; use amqp::Channel; use amqp::Session; use amqp::Table; - +use std::path::Path; use ircbot::config; @@ -38,7 +39,8 @@ fn main() { } let cfg = config::load(env::args().nth(1).unwrap().as_ref()); - let factoids = cfg.factoids().factoids; + let factoids_file = env::args().nth(2).unwrap(); + let factoids = Factoids::load(&Path::new(&factoids_file)).factoids; println!("{:?}", factoids.get("str1")); let mut session = Session::open_url(&cfg.rabbitmq.as_uri()).unwrap(); diff --git a/ircbot/src/config.rs b/ircbot/src/config.rs index 5b74566..921a502 100644 --- a/ircbot/src/config.rs +++ b/ircbot/src/config.rs @@ -3,7 +3,6 @@ use std::path::Path; use std::fs::File; use std::io::Read; -use ircbot::factoids::Factoids; use irc::client::prelude::Config as IrcConfig; #[derive(Serialize, Deserialize, Debug)] @@ -13,7 +12,6 @@ pub struct Config { password: String, channels: Vec, pub rabbitmq: RabbitMQConfig, - factoid_toml: String, } #[derive(Serialize, Deserialize, Debug)] @@ -37,10 +35,6 @@ impl RabbitMQConfig { } impl Config { - pub fn factoids(&self) -> Factoids { - Factoids::load(&Path::new(&self.factoid_toml)) - } - pub fn irc_config(&self) -> IrcConfig { IrcConfig { nickname: Some(self.nickname.clone()),