diff options
-rw-r--r-- | nancy.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/nancy.cpp b/nancy.cpp index 47f9c18..a5a1433 100644 --- a/nancy.cpp +++ b/nancy.cpp | |||
@@ -34,13 +34,22 @@ std::string capitalize(std::string input) | |||
34 | 34 | ||
35 | int main(int argc, char** argv) | 35 | int main(int argc, char** argv) |
36 | { | 36 | { |
37 | if (argc != 2) | ||
38 | { | ||
39 | std::cout << "usage: nancy [configfile]" << std::endl; | ||
40 | return -1; | ||
41 | } | ||
42 | |||
43 | std::string configfile(argv[1]); | ||
44 | YAML::Node config = YAML::LoadFile(configfile); | ||
45 | |||
37 | std::random_device random_device; | 46 | std::random_device random_device; |
38 | std::mt19937 random_engine{random_device()}; | 47 | std::mt19937 random_engine{random_device()}; |
39 | 48 | ||
40 | // Forms | 49 | // Forms |
41 | std::vector<std::string> forms; | 50 | std::vector<std::string> forms; |
42 | { | 51 | { |
43 | std::ifstream formfile("forms.txt"); | 52 | std::ifstream formfile(config["forms"].as<std::string>()); |
44 | if (formfile.is_open()) | 53 | if (formfile.is_open()) |
45 | { | 54 | { |
46 | while (!formfile.eof()) | 55 | while (!formfile.eof()) |
@@ -59,17 +68,15 @@ int main(int argc, char** argv) | |||
59 | 68 | ||
60 | if (forms.size() == 0) | 69 | if (forms.size() == 0) |
61 | { | 70 | { |
62 | std::cout << "No forms found... check forms.txt." << std::endl; | 71 | std::cout << "No forms found... check forms file." << std::endl; |
63 | 72 | ||
64 | return 2; | 73 | return 2; |
65 | } | 74 | } |
66 | 75 | ||
67 | // verbly | 76 | // verbly |
68 | verbly::data database("data.sqlite3"); | 77 | verbly::data database(config["verbly_datafile"].as<std::string>()); |
69 | 78 | ||
70 | 79 | ||
71 | YAML::Node config = YAML::LoadFile("config.yml"); | ||
72 | |||
73 | twitter::auth auth; | 80 | twitter::auth auth; |
74 | auth.setConsumerKey(config["consumer_key"].as<std::string>()); | 81 | auth.setConsumerKey(config["consumer_key"].as<std::string>()); |
75 | auth.setConsumerSecret(config["consumer_secret"].as<std::string>()); | 82 | auth.setConsumerSecret(config["consumer_secret"].as<std::string>()); |