some improvements

This commit is contained in:
Petr Bena 2014-05-25 14:44:45 +02:00
parent d33129f7c2
commit 30eed46b4f
5 changed files with 27 additions and 1 deletions

View File

@ -13,3 +13,15 @@ make
``` ```
NOTE: you need to have libcurl-dev installed in your system NOTE: you need to have libcurl-dev installed in your system
Usage
=====
./stikkit -b <url>
# now type text and hit ctrl+d to exit
cat <file> | stikkit -b <url>
<url> is an url to stikked server for example, if your server is http://something.blah/stikked and your api is http://something.blah/stikked/api then use http://something.blah/stikked as parameter to -b
The url parameter can be stored to configuration file (stikkit will ask you in case there is none in config file)

View File

@ -22,6 +22,7 @@ unsigned int Configuration::Verbosity = 0;
string Configuration::Source = ""; string Configuration::Source = "";
string Configuration::URL = ""; string Configuration::URL = "";
string Configuration::Expiry = "60"; string Configuration::Expiry = "60";
bool Configuration::Private = false;
string Configuration::Author = ""; string Configuration::Author = "";
string Configuration::Version = "1.0.0"; string Configuration::Version = "1.0.0";
string Configuration::Title = ""; string Configuration::Title = "";

View File

@ -31,6 +31,7 @@ namespace Stikkit
static string Version; static string Version;
static string Expiry; static string Expiry;
static string DefaultURL; static string DefaultURL;
static bool Private;
static string Home; static string Home;
}; };
} }

View File

@ -91,6 +91,15 @@ int main(int argc, char *argv[])
post += curl_easy_escape(curl, Stikkit::Configuration::Source.c_str(), Stikkit::Configuration::Source.length()); post += curl_easy_escape(curl, Stikkit::Configuration::Source.c_str(), Stikkit::Configuration::Source.length());
post += "&name="; post += "&name=";
post += curl_easy_escape(curl, Stikkit::Configuration::Author.c_str(), Stikkit::Configuration::Author.length()); post += curl_easy_escape(curl, Stikkit::Configuration::Author.c_str(), Stikkit::Configuration::Author.length());
if (Stikkit::Configuration::Title.length() > 0)
{
post += "&title=";
post += curl_easy_escape(curl, Stikkit::Configuration::Title.c_str(), Stikkit::Configuration::Title.length());
}
if (Stikkit::Configuration::Private)
post += "&private=1";
if (Stikkit::Configuration::Expiry != "0")
post += "&expire=" + Stikkit::Configuration::Expiry;
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_URL, Stikkit::Configuration::URL.c_str()); curl_easy_setopt(curl, CURLOPT_URL, Stikkit::Configuration::URL.c_str());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str()); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str());

View File

@ -106,9 +106,12 @@ void TerminalParser::DisplayHelp()
cout << "Stikkit - open source pastebin uploader for Stikked\n\n"\ cout << "Stikkit - open source pastebin uploader for Stikked\n\n"\
"Parameters:\n"\ "Parameters:\n"\
" -a <name>: Specify author name\n"\ " -a <name>: Specify author name by default the current OS username is used\n"\
" -b <url>: Specify URL of Stikked server\n"\ " -b <url>: Specify URL of Stikked server\n"\
" -v: Increases verbosity\n"\ " -v: Increases verbosity\n"\
" -t <title>: Set a title for a paste\n"\
" -p: Mark a paste as private (not visible in recent pastes)\n"\
" -e <minutes>: Set expiry in minutes, parameter needs to be a number\n"\
" --version: Display a version\n"\ " --version: Display a version\n"\
" -h | --help: Display this help\n\n"\ " -h | --help: Display this help\n\n"\
"Note: every argument in [brackets] is optional\n"\ "Note: every argument in [brackets] is optional\n"\