mirror of
https://github.com/benapetr/stikkit.git
synced 2025-04-26 04:51:09 -05:00
Merge branch 'master' into ubuntu
This commit is contained in:
commit
40c5f3d147
15
README.md
15
README.md
@ -11,6 +11,18 @@ Features
|
||||
* Automatically url encodes all data
|
||||
* 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
|
||||
=================
|
||||
|
||||
@ -30,10 +42,9 @@ Usage
|
||||
```
|
||||
stikkit -b url
|
||||
# now type text and hit ctrl+d to exit
|
||||
```
|
||||
|
||||
cat file | stikkit -b url
|
||||
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
|
||||
|
||||
|
@ -24,9 +24,10 @@ string Configuration::URL = "";
|
||||
string Configuration::Expiry = "60";
|
||||
bool Configuration::Private = false;
|
||||
string Configuration::Author = "";
|
||||
string Configuration::Version = "1.0.3";
|
||||
string Configuration::Version = "1.0.4";
|
||||
string Configuration::Title = "";
|
||||
string Configuration::Home = "";
|
||||
string Configuration::Input = "";
|
||||
string Configuration::DefaultURL = "";
|
||||
|
||||
void Configuration::Init()
|
||||
|
@ -8,9 +8,12 @@
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
//GNU General Public License for more details.
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <errno.h>
|
||||
#include <string>
|
||||
#include <curl/curl.h>
|
||||
#include <fstream>
|
||||
#include "configuration.hpp"
|
||||
#include "terminalparser.hpp"
|
||||
#include "syslog.hpp"
|
||||
@ -70,8 +73,23 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
Stikkit::Configuration::URL += "/api/create";
|
||||
std::string line;
|
||||
while (getline(std::cin, line))
|
||||
Stikkit::Configuration::Source += line + "\n";
|
||||
if (Stikkit::Configuration::Input.length())
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
Stikkit::Syslog::Log("Refusing to upload empty string");
|
||||
|
@ -70,7 +70,7 @@ bool TerminalParser::Parse()
|
||||
Configuration::Title = this->argv[x];
|
||||
} 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;
|
||||
}
|
||||
} else if (text.at(0) == 'e')
|
||||
@ -81,11 +81,21 @@ bool TerminalParser::Parse()
|
||||
Configuration::Expiry = this->argv[x];
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
text = text.substr(1);
|
||||
}
|
||||
valid = true;
|
||||
@ -135,6 +145,7 @@ void TerminalParser::DisplayHelp()
|
||||
" -a <name>: Specify author name by default the current\n"\
|
||||
" OS username is used\n"\
|
||||
" -b <url>: Specify URL of Stikked server\n"\
|
||||
" -i <file>: Upload a content of specified file\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"\
|
||||
|
Loading…
x
Reference in New Issue
Block a user