summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2016-12-13 18:47:30 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2016-12-13 18:47:30 -0500
commit0b9af5d95b281049cbf50e3eb6f3e738b1da393a (patch)
tree91b3204bbd8dacd09847cb553d39ba731d7fa1f8
parent6979f41ee930e72f94420dedf594f24e0cba2c0d (diff)
downloadchemist-0b9af5d95b281049cbf50e3eb6f3e738b1da393a.tar.gz
chemist-0b9af5d95b281049cbf50e3eb6f3e738b1da393a.tar.bz2
chemist-0b9af5d95b281049cbf50e3eb6f3e738b1da393a.zip
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.
-rw-r--r--chemist.cpp15
1 files 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 @@
10 10
11int main(int argc, char** argv) 11int main(int argc, char** argv)
12{ 12{
13 YAML::Node config = YAML::LoadFile("config.yml"); 13 if (argc != 2)
14 {
15 std::cout << "usage: chemist [configfile]" << std::endl;
16 return -1;
17 }
18
19 std::string configfile(argv[1]);
20 YAML::Node config = YAML::LoadFile(configfile);
14 21
15 twitter::auth auth; 22 twitter::auth auth;
16 auth.setConsumerKey(config["consumer_key"].as<std::string>()); 23 auth.setConsumerKey(config["consumer_key"].as<std::string>());
@@ -21,10 +28,10 @@ int main(int argc, char** argv)
21 twitter::client client(auth); 28 twitter::client client(auth);
22 29
23 std::map<std::string, std::vector<std::string>> groups; 30 std::map<std::string, std::vector<std::string>> groups;
24 std::ifstream datafile("data.txt"); 31 std::ifstream datafile(config["forms_file"].as<std::string>());
25 if (!datafile.is_open()) 32 if (!datafile.is_open())
26 { 33 {
27 std::cout << "Could not find data.txt" << std::endl; 34 std::cout << "Could not find datafile" << std::endl;
28 return 1; 35 return 1;
29 } 36 }
30 37
@@ -55,7 +62,7 @@ int main(int argc, char** argv)
55 std::random_device random_device; 62 std::random_device random_device;
56 std::mt19937 random_engine{random_device()}; 63 std::mt19937 random_engine{random_device()};
57 64
58 verbly::data database {"data.sqlite3"}; 65 verbly::data database {config["verbly_datafile"].as<std::string>()};
59 for (;;) 66 for (;;)
60 { 67 {
61 std::cout << "Generating tweet" << std::endl; 68 std::cout << "Generating tweet" << std::endl;