Merge branch 'master' into ubuntu

This commit is contained in:
Petr Bena 2014-05-25 18:24:41 +02:00
commit 40c5f3d147
4 changed files with 49 additions and 8 deletions

View File

@ -11,6 +11,18 @@ Features
* Automatically url encodes all data * Automatically url encodes all data
* Automatically figure out author name if not provided explicitly * Automatically figure out author name if not provided explicitly
Installing on debian or ubuntu
==============================
Just add ppa:
```
sudo add-apt-repository ppa:benapetr/misc
sudo apt-get update
sudo apt-get install stikkit
```
That's all
Building on linux Building on linux
================= =================
@ -30,10 +42,9 @@ Usage
``` ```
stikkit -b url stikkit -b url
# now type text and hit ctrl+d to exit # now type text and hit ctrl+d to exit
```
cat file | stikkit -b url cat file | stikkit -b url
echo "Hello world" | stikkit echo "Hello world" | stikkit
```
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 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

View File

@ -24,9 +24,10 @@ string Configuration::URL = "";
string Configuration::Expiry = "60"; string Configuration::Expiry = "60";
bool Configuration::Private = false; bool Configuration::Private = false;
string Configuration::Author = ""; string Configuration::Author = "";
string Configuration::Version = "1.0.3"; string Configuration::Version = "1.0.4";
string Configuration::Title = ""; string Configuration::Title = "";
string Configuration::Home = ""; string Configuration::Home = "";
string Configuration::Input = "";
string Configuration::DefaultURL = ""; string Configuration::DefaultURL = "";
void Configuration::Init() void Configuration::Init()

View File

@ -8,9 +8,12 @@
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details. //GNU General Public License for more details.
#include <cstring>
#include <iostream> #include <iostream>
#include <errno.h>
#include <string> #include <string>
#include <curl/curl.h> #include <curl/curl.h>
#include <fstream>
#include "configuration.hpp" #include "configuration.hpp"
#include "terminalparser.hpp" #include "terminalparser.hpp"
#include "syslog.hpp" #include "syslog.hpp"
@ -70,8 +73,23 @@ int main(int argc, char *argv[])
} }
Stikkit::Configuration::URL += "/api/create"; Stikkit::Configuration::URL += "/api/create";
std::string line; std::string line;
while (getline(std::cin, line)) if (Stikkit::Configuration::Input.length())
Stikkit::Configuration::Source += line + "\n"; {
// user wants to upload some file
std::ifstream infile(Stikkit::Configuration::Input.c_str());
if (!infile)
{
cerr << "File could not be opened!" << endl;
cerr << "Error code: " << strerror(errno) << endl;
return 61;
}
while (std::getline(infile, line))
Stikkit::Configuration::Source += line + "\n";
} else
{
while (getline(std::cin, line))
Stikkit::Configuration::Source += line + "\n";
}
if (Stikkit::Configuration::Source.size() < 1) if (Stikkit::Configuration::Source.size() < 1)
{ {
Stikkit::Syslog::Log("Refusing to upload empty string"); Stikkit::Syslog::Log("Refusing to upload empty string");

View File

@ -70,7 +70,7 @@ bool TerminalParser::Parse()
Configuration::Title = this->argv[x]; Configuration::Title = this->argv[x];
} else } else
{ {
cerr << "Parameter -b requires an argument for it to work!" << endl; cerr << "Parameter -t requires an argument for it to work!" << endl;
return true; return true;
} }
} else if (text.at(0) == 'e') } else if (text.at(0) == 'e')
@ -81,11 +81,21 @@ bool TerminalParser::Parse()
Configuration::Expiry = this->argv[x]; Configuration::Expiry = this->argv[x];
} else } else
{ {
cerr << "Parameter -b requires an argument for it to work!" << endl; cerr << "Parameter -e requires an argument for it to work!" << endl;
return true;
}
} else if (text.at(0) == 'i')
{
if (this->argc > x + 1 && !this->argv[x + 1][0] != '-')
{
x++;
Configuration::Input = this->argv[x];
} else
{
cerr << "Parameter -i requires an argument for it to work!" << endl;
return true; return true;
} }
} }
text = text.substr(1); text = text.substr(1);
} }
valid = true; valid = true;
@ -135,6 +145,7 @@ void TerminalParser::DisplayHelp()
" -a <name>: Specify author name by default the current\n"\ " -a <name>: Specify author name by default the current\n"\
" OS username is used\n"\ " OS username is used\n"\
" -b <url>: Specify URL of Stikked server\n"\ " -b <url>: Specify URL of Stikked server\n"\
" -i <file>: Upload a content of specified file\n"\
" -v: Increases verbosity\n"\ " -v: Increases verbosity\n"\
" -t <title>: Set a title for a paste\n"\ " -t <title>: Set a title for a paste\n"\
" -p: Mark a paste as private (not visible in recent pastes)\n"\ " -p: Mark a paste as private (not visible in recent pastes)\n"\