diff --git a/stikkit/configuration.cpp b/stikkit/configuration.cpp index 912836b..5e1665f 100644 --- a/stikkit/configuration.cpp +++ b/stikkit/configuration.cpp @@ -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()); diff --git a/stikkit/configuration.hpp b/stikkit/configuration.hpp index d0178b3..dd10548 100644 --- a/stikkit/configuration.hpp +++ b/stikkit/configuration.hpp @@ -34,6 +34,7 @@ namespace Stikkit static bool Private; static string Home; static string Apikey; + static string Lang; static bool NoExtras; }; } diff --git a/stikkit/main.cpp b/stikkit/main.cpp index 75ee00b..65e97f6 100644 --- a/stikkit/main.cpp +++ b/stikkit/main.cpp @@ -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="; diff --git a/stikkit/terminalparser.cpp b/stikkit/terminalparser.cpp index d47af67..8c86f1a 100644 --- a/stikkit/terminalparser.cpp +++ b/stikkit/terminalparser.cpp @@ -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 : Set expiry in minutes, parameter needs\n"\ " to be a number, default: unlimited time\n"\ " -k : Set api key for current server\n"\ + " -l : 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"\