rss-cli/src/main.cpp

51 lines
1000 B
C++
Raw Normal View History

2021-07-24 01:17:22 +00:00
///////////////////////////////////////////////////////////////////////////////
// Tyler Perkins
// 7-23-21
// entry point
//
#include <iostream>
2021-07-24 02:34:13 +00:00
#include <string>
2021-07-24 02:13:35 +00:00
#include <getopt.h>
2021-07-24 02:34:13 +00:00
2021-07-24 01:17:22 +00:00
#include "config.hpp"
2021-07-24 03:24:20 +00:00
#include "rss_out.hpp"
2021-07-24 02:34:13 +00:00
#include "options.hpp"
2021-07-24 01:17:22 +00:00
#include "rss.hpp"
#if _TESTS_ == 1
#include "tests.hpp"
#endif
int main(int argc, char** argv) {
#if _TESTS_ == 1
rss_utils::testRSS();
2021-07-25 17:40:52 +00:00
rss_utils::testItems();
2021-07-24 01:17:22 +00:00
return 0;
#endif
2021-07-24 02:13:35 +00:00
//get the passed options
option_flags* opts = parse_options(argc, argv);
//setup the rss object
2021-07-24 02:34:13 +00:00
rss_utils::rss feed(opts->uri);
if(!feed.isOk())
exit(-1);
2021-07-25 21:05:40 +00:00
//display requested attributes and items
2021-07-25 21:15:47 +00:00
std::string output = "";
if(!rss_utils::rss_opts_empty(opts))
output = rss_utils::rss_to_list(feed, opts);
2021-07-24 02:34:13 +00:00
2021-07-25 21:05:40 +00:00
if(opts->items != nullptr){
feed.getItems();
output += "\n" + rss_utils::rss_to_items(feed, opts);
}
2021-07-24 01:17:22 +00:00
2021-07-25 21:05:40 +00:00
std::cout << output << std::endl;
2021-07-24 02:13:35 +00:00
2021-07-24 03:24:20 +00:00
delete opts;
2021-07-24 02:13:35 +00:00
return 0;
2021-07-24 01:17:22 +00:00
}