Added "pastebincl --syntaxlist" option (displays possible syntax), and updated manpage.
This commit is contained in:
parent
03b7e93c4b
commit
d00f978d5e
6 changed files with 46 additions and 18 deletions
|
@ -39,7 +39,7 @@ ConfigRead::ConfigRead(string filepath)
|
|||
{
|
||||
ifstream infile(filepath.c_str(), ios_base::in);
|
||||
if(!infile)
|
||||
throw -1;
|
||||
throw -42; // ANTI-ANSWER!!!1
|
||||
|
||||
string filecontent=unxor(infile);
|
||||
|
||||
|
|
3
data.h
3
data.h
|
@ -35,6 +35,7 @@
|
|||
#define DEF_DATA
|
||||
|
||||
#include "data_devcode.h" // TODO before compile, check this file
|
||||
#include "data_paramlist.h"
|
||||
|
||||
// TODO REDEFINE YOUR OS HERE!
|
||||
#define UNIX
|
||||
|
@ -53,7 +54,7 @@
|
|||
#define DEFAULT_CONFIGPATH ".pastebinclrc"
|
||||
|
||||
enum FlagParameter {
|
||||
P_NAME=1, P_SYNTAX=2, P_PRIVATE=4, P_EXPIRE=8, P_GUEST=16, P_HELP=32, P_VERSION=64, P_LICENCE=128, P_USERGEN=256
|
||||
P_NAME=1, P_SYNTAX=2, P_PRIVATE=4, P_EXPIRE=8, P_GUEST=16, P_HELP=32, P_VERSION=64, P_LICENCE=128, P_USERGEN=256, P_SYNTAXLIST=512
|
||||
};
|
||||
|
||||
#define SOFT_VERSION "0.1 INDEV"
|
||||
|
|
42
func.cpp
42
func.cpp
|
@ -72,6 +72,11 @@ bool checkParameterRead(ParameterRead& pr, unsigned& flags)
|
|||
flags=P_VERSION;
|
||||
return true;
|
||||
}
|
||||
if(pr.isSet("syntaxlist"))
|
||||
{
|
||||
flags=P_SYNTAXLIST;
|
||||
return true;
|
||||
}
|
||||
if((pr.isSet("n") && pr.isValueSet("n", true)) || (pr.isSet("name") && pr.isValueSet("name", true)))
|
||||
flags+=P_NAME;
|
||||
if((pr.isSet("s") && pr.isValueSet("s", true)) || (pr.isSet("syntax") && pr.isValueSet("syntax", true)))
|
||||
|
@ -118,6 +123,10 @@ void showVersion()
|
|||
<< "Contact: <contact@tobast.fr> or contact feature at http://tobast.fr/" << std::endl
|
||||
<< "Error report: <error-report@tobast.fr>" << std::endl << std::endl;
|
||||
}
|
||||
void showSyntaxList()
|
||||
{
|
||||
std::cout << SYNTAX_LIST << std::endl;
|
||||
}
|
||||
|
||||
bool userGen()
|
||||
{
|
||||
|
@ -191,25 +200,32 @@ CurlPost* preparePostRequest(const unsigned& flags, ParameterRead& pr, std::stri
|
|||
|
||||
std::string getUserCode()
|
||||
{
|
||||
ConfigRead cr(getConfigPath());
|
||||
try {
|
||||
ConfigRead cr(getConfigPath());
|
||||
|
||||
CurlPost* request=new CurlPost(PASTEBIN_USERCODE_URL);
|
||||
CurlPost* request=new CurlPost(PASTEBIN_USERCODE_URL);
|
||||
|
||||
request->setPostData("api_dev_key", DEVELOPPER_CODE);
|
||||
request->setPostData("api_user_name", cr.getUser());
|
||||
request->setPostData("api_user_password", cr.getPass());
|
||||
request->setPostData("api_dev_key", DEVELOPPER_CODE);
|
||||
request->setPostData("api_user_name", cr.getUser());
|
||||
request->setPostData("api_user_password", cr.getPass());
|
||||
|
||||
std::string result=request->execute();
|
||||
std::string result=request->execute();
|
||||
|
||||
delete request;
|
||||
delete request;
|
||||
|
||||
if(result.find("Bad API request") != std::string::npos) // FAIL!
|
||||
{
|
||||
std::cerr << result << std::endl;
|
||||
throw -1;
|
||||
if(result.find("Bad API request") != std::string::npos) // FAIL!
|
||||
{
|
||||
std::cerr << result << std::endl;
|
||||
throw -1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
catch(const int& e) {
|
||||
if(e==-42) // Couldn't open file, let's assume no password was set
|
||||
std::cerr << "Warning: couldn't open file " << getConfigPath() << ". Run 'pastebincl --usergen' to be able to post as a registered user." << std::endl;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string getPasteContent()
|
||||
|
|
1
func.h
1
func.h
|
@ -56,6 +56,7 @@ bool checkParameterRead(ParameterRead& pr, unsigned& flags);
|
|||
void showLicence();
|
||||
void showHelp();
|
||||
void showVersion();
|
||||
void showSyntaxList();
|
||||
|
||||
bool userGen();
|
||||
|
||||
|
|
2
main.cpp
2
main.cpp
|
@ -57,6 +57,8 @@ int main(int argc, char** argv)
|
|||
showHelp();
|
||||
else if(parameterFlags & P_VERSION)
|
||||
showVersion();
|
||||
else if(parameterFlags & P_SYNTAXLIST)
|
||||
showSyntaxList();
|
||||
else if(parameterFlags & P_USERGEN)
|
||||
{
|
||||
if(userGen())
|
||||
|
|
12
manpage
12
manpage
|
@ -28,13 +28,21 @@ DESCRIPTION
|
|||
|
||||
-s [syntax], --syntax=[syntax]
|
||||
Defines [syntax] as the syntax highlighting pattern of your text, eg. "c" or "lolcode" (see the full list on http://pastebin.com/).
|
||||
To display the complete list, run "pastebincl --syntaxlist".
|
||||
|
||||
--syntaxlist
|
||||
Displays the complete list of "syntax" parameters (see "-s").
|
||||
|
||||
-e [expire_time], --expire [expire_time]
|
||||
Defines [expire_time] as the time before the paste expires. Possible values :
|
||||
- TODO
|
||||
- N = Never
|
||||
- 10M = 10 Minutes
|
||||
- 1H = 1 Hour
|
||||
- 1D = 1 Day
|
||||
- 1M = 1 Month
|
||||
|
||||
-p, --private
|
||||
Posts a private past instead of a public one.
|
||||
Posts a private past instead of a public one. A private paste willn't be displayed in the latest pastes, neither than be indexed by search engines.
|
||||
|
||||
-g, --guest
|
||||
Posts the paste as a guest. It's the default option if no configuration file was set.
|
||||
|
|
Loading…
Reference in a new issue