From 0b9af5d95b281049cbf50e3eb6f3e738b1da393a Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 13 Dec 2016 18:47:30 -0500 Subject: Bot now takes path to config file as argument That config file now also has to contain the paths to the verbly datafile and the data.txt file. --- chemist.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/chemist.cpp b/chemist.cpp index 8b00d12..06e1992 100644 --- a/chemist.cpp +++ b/chemist.cpp @@ -10,7 +10,14 @@ int main(int argc, char** argv) { - YAML::Node config = YAML::LoadFile("config.yml"); + if (argc != 2) + { + std::cout << "usage: chemist [configfile]" << std::endl; + return -1; + } + + std::string configfile(argv[1]); + YAML::Node config = YAML::LoadFile(configfile); twitter::auth auth; auth.setConsumerKey(config["consumer_key"].as()); @@ -21,10 +28,10 @@ int main(int argc, char** argv) twitter::client client(auth); std::map> groups; - std::ifstream datafile("data.txt"); + std::ifstream datafile(config["forms_file"].as()); if (!datafile.is_open()) { - std::cout << "Could not find data.txt" << std::endl; + std::cout << "Could not find datafile" << std::endl; return 1; } @@ -55,7 +62,7 @@ int main(int argc, char** argv) std::random_device random_device; std::mt19937 random_engine{random_device()}; - verbly::data database {"data.sqlite3"}; + verbly::data database {config["verbly_datafile"].as()}; for (;;) { std::cout << "Generating tweet" << std::endl; -- cgit 1.4.1