mirror of
https://github.com/benapetr/stikkit.git
synced 2025-04-25 20:41:20 -05:00
Added support for -l <lang> and /etc/stikkit/apikey
This commit is contained in:
parent
dcba663d8d
commit
efbdaa0c6d
@ -31,6 +31,7 @@ bool Configuration::NoExtras = false;
|
||||
string Configuration::Input = "";
|
||||
string Configuration::DefaultURL = "";
|
||||
string Configuration::Apikey = "";
|
||||
string Configuration::Lang = "";
|
||||
|
||||
void Configuration::Init()
|
||||
{
|
||||
@ -49,6 +50,17 @@ void Configuration::Init()
|
||||
}
|
||||
f.close();
|
||||
}
|
||||
if (stat("/etc/stikkit/apikey", &st) != -1)
|
||||
{
|
||||
ifstream f;
|
||||
f.open("/etc/stikkit/apikey");
|
||||
string line;
|
||||
if (getline(f, line))
|
||||
{
|
||||
Configuration::Apikey = line;
|
||||
}
|
||||
f.close();
|
||||
}
|
||||
if (stat(string(homedir + "/.stikkit").c_str(), &st) == -1)
|
||||
{
|
||||
mkdir(string(homedir + "/.stikkit").c_str(), 0750);
|
||||
@ -73,6 +85,16 @@ void Configuration::Init()
|
||||
}
|
||||
fapi.close();
|
||||
|
||||
//Lang
|
||||
ifstream flang;
|
||||
flang.open(string(homedir + "/.stikkit/lang").c_str());
|
||||
string linelang;
|
||||
if(getline(flang, linelang))
|
||||
{
|
||||
Configuration::Lang = linelang;
|
||||
}
|
||||
flang.close();
|
||||
|
||||
//expiry
|
||||
ifstream fexp;
|
||||
fexp.open(string(homedir + "/.stikkit/expiry").c_str());
|
||||
|
@ -34,6 +34,7 @@ namespace Stikkit
|
||||
static bool Private;
|
||||
static string Home;
|
||||
static string Apikey;
|
||||
static string Lang;
|
||||
static bool NoExtras;
|
||||
};
|
||||
}
|
||||
|
@ -109,6 +109,12 @@ int main(int argc, char *argv[])
|
||||
Stikkit::Configuration::URL += curl_easy_escape(curl, Stikkit::Configuration::Apikey.c_str(), Stikkit::Configuration::Apikey.length());
|
||||
}
|
||||
|
||||
if (Stikkit::Configuration::Lang.length() > 0)
|
||||
{
|
||||
post += "&lang=";
|
||||
post += curl_easy_escape(curl, Stikkit::Configuration::Lang.c_str(), Stikkit::Configuration::Lang.length());
|
||||
}
|
||||
|
||||
if (Stikkit::Configuration::Author.length() > 0)
|
||||
{
|
||||
post += "&name=";
|
||||
|
@ -106,6 +106,17 @@ bool TerminalParser::Parse()
|
||||
cerr << "Parameter -k requires an argument for it to work!" << endl;
|
||||
return true;
|
||||
}
|
||||
} else if (text.at(0) == 'l')
|
||||
{
|
||||
if (this->argc > x + 1 && !this->argv[x + 1][0] != '-')
|
||||
{
|
||||
x++;
|
||||
Configuration::Lang = this->argv[x];
|
||||
} else
|
||||
{
|
||||
cerr << "Parameter -l requires an argument for it to work!" << endl;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
text = text.substr(1);
|
||||
}
|
||||
@ -161,6 +172,7 @@ void TerminalParser::DisplayHelp()
|
||||
" -e <minutes>: Set expiry in minutes, parameter needs\n"\
|
||||
" to be a number, default: unlimited time\n"\
|
||||
" -k <apikey>: Set api key for current server\n"\
|
||||
" -l <lang>: Set paste lang for syntax highlighting\n"\
|
||||
" --version: Display a version\n"\
|
||||
" -h | --help: Display this help\n\n"\
|
||||
"Note: every argument in [brackets] is optional\n"\
|
||||
|
Loading…
x
Reference in New Issue
Block a user