Added "pastebincl --syntaxlist" option (displays possible syntax), and updated manpage.

This commit is contained in:
tobast 2011-12-25 01:34:27 +01:00
parent 03b7e93c4b
commit d00f978d5e
6 changed files with 46 additions and 18 deletions

View file

@ -39,7 +39,7 @@ ConfigRead::ConfigRead(string filepath)
{ {
ifstream infile(filepath.c_str(), ios_base::in); ifstream infile(filepath.c_str(), ios_base::in);
if(!infile) if(!infile)
throw -1; throw -42; // ANTI-ANSWER!!!1
string filecontent=unxor(infile); string filecontent=unxor(infile);

3
data.h
View file

@ -35,6 +35,7 @@
#define DEF_DATA #define DEF_DATA
#include "data_devcode.h" // TODO before compile, check this file #include "data_devcode.h" // TODO before compile, check this file
#include "data_paramlist.h"
// TODO REDEFINE YOUR OS HERE! // TODO REDEFINE YOUR OS HERE!
#define UNIX #define UNIX
@ -53,7 +54,7 @@
#define DEFAULT_CONFIGPATH ".pastebinclrc" #define DEFAULT_CONFIGPATH ".pastebinclrc"
enum FlagParameter { 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" #define SOFT_VERSION "0.1 INDEV"

View file

@ -72,6 +72,11 @@ bool checkParameterRead(ParameterRead& pr, unsigned& flags)
flags=P_VERSION; flags=P_VERSION;
return true; 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))) if((pr.isSet("n") && pr.isValueSet("n", true)) || (pr.isSet("name") && pr.isValueSet("name", true)))
flags+=P_NAME; flags+=P_NAME;
if((pr.isSet("s") && pr.isValueSet("s", true)) || (pr.isSet("syntax") && pr.isValueSet("syntax", true))) 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 << "Contact: <contact@tobast.fr> or contact feature at http://tobast.fr/" << std::endl
<< "Error report: <error-report@tobast.fr>" << std::endl << std::endl; << "Error report: <error-report@tobast.fr>" << std::endl << std::endl;
} }
void showSyntaxList()
{
std::cout << SYNTAX_LIST << std::endl;
}
bool userGen() bool userGen()
{ {
@ -191,6 +200,7 @@ CurlPost* preparePostRequest(const unsigned& flags, ParameterRead& pr, std::stri
std::string getUserCode() std::string getUserCode()
{ {
try {
ConfigRead cr(getConfigPath()); ConfigRead cr(getConfigPath());
CurlPost* request=new CurlPost(PASTEBIN_USERCODE_URL); CurlPost* request=new CurlPost(PASTEBIN_USERCODE_URL);
@ -211,6 +221,12 @@ std::string getUserCode()
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() std::string getPasteContent()
{ {

1
func.h
View file

@ -56,6 +56,7 @@ bool checkParameterRead(ParameterRead& pr, unsigned& flags);
void showLicence(); void showLicence();
void showHelp(); void showHelp();
void showVersion(); void showVersion();
void showSyntaxList();
bool userGen(); bool userGen();

View file

@ -57,6 +57,8 @@ int main(int argc, char** argv)
showHelp(); showHelp();
else if(parameterFlags & P_VERSION) else if(parameterFlags & P_VERSION)
showVersion(); showVersion();
else if(parameterFlags & P_SYNTAXLIST)
showSyntaxList();
else if(parameterFlags & P_USERGEN) else if(parameterFlags & P_USERGEN)
{ {
if(userGen()) if(userGen())

12
manpage
View file

@ -28,13 +28,21 @@ DESCRIPTION
-s [syntax], --syntax=[syntax] -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/). 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] -e [expire_time], --expire [expire_time]
Defines [expire_time] as the time before the paste expires. Possible values : 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 -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 -g, --guest
Posts the paste as a guest. It's the default option if no configuration file was set. Posts the paste as a guest. It's the default option if no configuration file was set.