Add ability to accept stdin from URI

This commit is contained in:
Clortox 2021-07-26 19:24:55 -04:00
parent 23f332035c
commit 25bfd0cfc7
3 changed files with 26 additions and 17 deletions

View File

@ -34,6 +34,8 @@ Usage: ./bin/rss-cli [-u FEED_URI] [CHANNEL FLAGS] [-i ITEM_INDEX] [ITEM FLAGS]
Options: Options:
Required Options: Required Options:
[-u, --uri] URI URI of the rss stream [-u, --uri] URI URI of the rss stream
Also accepts '-' to take input
from stdin (stops once a newline is reached)
Channel information: Channel information:
[-t, --title] Get title of channel [-t, --title] Get title of channel

View File

@ -11,7 +11,9 @@ void help(char* progName){
std::cout << "[-i ITEM_INDEX] [ITEM FLAGS]\n"; std::cout << "[-i ITEM_INDEX] [ITEM FLAGS]\n";
std::cout << "Options:\n"; std::cout << "Options:\n";
std::cout << "Required Options:\n"; std::cout << "Required Options:\n";
std::cout << " [-u, --uri] URI URI of the rss stream\n\n"; std::cout << " [-u, --uri] URI URI of the rss stream\n";
std::cout << " Also accepts '-' to take input\n";
std::cout << " from stdin (stops once a newline is reached)\n\n";
std::cout << "Channel information:\n"; std::cout << "Channel information:\n";
std::cout << " [-t, --title] Get title of channel\n"; std::cout << " [-t, --title] Get title of channel\n";

View File

@ -77,6 +77,10 @@ std::string rss::getURI() const { return _uri; }
bool rss::update() { bool rss::update() {
std::string result; std::string result;
if(_uri == "-"){
std::getline(std::cin, result);
return parse(result);
} else {
CURL *curl; CURL *curl;
CURLcode res; CURLcode res;
curl = curl_easy_init(); curl = curl_easy_init();
@ -98,6 +102,7 @@ bool rss::update() {
_ok = false; _ok = false;
return false; return false;
} }
}
std::string rss::getTitle() const { std::string rss::getTitle() const {
if(!_ok) if(!_ok)