From 6ce9e71bd0f188bcb5a66ecbad8af348b3e348af Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 14 Dec 2016 02:10:28 -0500 Subject: Bot now takes path to config file as argument That config file now also has to contain the path to the image to post. --- snitch.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'snitch.cpp') diff --git a/snitch.cpp b/snitch.cpp index 700a0a9..3758dc0 100644 --- a/snitch.cpp +++ b/snitch.cpp @@ -8,7 +8,14 @@ int main(int argc, char** argv) { - YAML::Node config = YAML::LoadFile("config.yml"); + if (argc != 2) + { + std::cout << "usage: snitch [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()); @@ -16,7 +23,7 @@ int main(int argc, char** argv) auth.setAccessKey(config["access_key"].as()); auth.setAccessSecret(config["access_secret"].as()); - std::ifstream img_file("image.jpg"); + std::ifstream img_file(config["image"].as()); img_file.seekg(0, std::ios::end); size_t img_len = img_file.tellg(); char* img_buf = new char[img_len]; -- cgit 1.4.1