PhoenixLecture  2.0.0
Set of tools to make lectures
main.cpp File Reference
#include "OptionParser.h"
#include "psrc_split_lib.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

OptionParser createOptionParser ()
 Create the OptionParser of this program. More...
 
int main (int argc, char **argv)
 

Function Documentation

◆ createOptionParser()

OptionParser createOptionParser ( )

Create the OptionParser of this program.

Returns
OptionParser of this program

Definition at line 14 of file main.cpp.

14  {
15  OptionParser parser(true, __PROGRAM_VERSION__);
16  parser.setExampleLongOption("phoenix_psrcsplittex --input=fileInput.cpp --output=output.ptex --platex");
17  parser.setExampleShortOption("phoenix_psrcsplittex -i fileInput.cpp -o output.ptex -p");
18 
19  parser.addOption("input", "i", OptionType::FILENAME, true, "name of the input file (source, c, cpp, cmake, py, cu)");
20 
21  PPath defaultOutputFile("./output.txt");
22  parser.addOption("output", "o", defaultOutputFile, "output file to be generated");
23 
24  parser.addOption("keepcomment", "k", OptionType::NONE, false, "keep the comment of the targeted language");
25  parser.addOption("keeptex", "t", OptionType::NONE, false, "keep the ptex comment in the output file");
26  parser.addOption("removefirstcomment", "f", OptionType::NONE, false, "remove the first comment of the file (can be the Licence or whatever)");
27  parser.addOption("platex", "p", OptionType::NONE, false, "activate platex mode (add begin and end around code part)");
28 
29  return parser;
30 }
Parse the options passed to a program.
Definition: OptionParser.h:15
Path of a directory or a file.
Definition: PPath.h:17

References OptionParser::addOption(), OptionType::FILENAME, OptionType::NONE, OptionParser::setExampleLongOption(), and OptionParser::setExampleShortOption().

+ Here is the call graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 32 of file main.cpp.

32  {
34  parser.parseArgument(argc, argv);
35 
36  const OptionMode & defaultMode = parser.getDefaultMode();
37  PPath inputFile;
38  defaultMode.getValue(inputFile, "input");
39 
40  PPath outputDir(".");
41  defaultMode.getValue(outputDir, "output");
42 
43  bool keepComment(false), keepTex(false), removefirstcomment(false), isPlatexMode(false);
44  keepComment = defaultMode.isOptionExist("keepcomment");
45  keepTex = defaultMode.isOptionExist("keeptex");
46  removefirstcomment = defaultMode.isOptionExist("removefirstcomment");
47  isPlatexMode = defaultMode.isOptionExist("platex");
48 
49  bool b(processFile(outputDir, inputFile, keepComment, keepTex, removefirstcomment, isPlatexMode));
50  return b - 1;
51 }
OptionParser createOptionParser()
Create the OptionParser of this program.
Definition: main.cpp:17
bool processFile(const PPath &inputFile, const PString &command, size_t firstToken, size_t lastToken, size_t incrementToken, const PString &delimitor, bool isNoFail)
Process the file.
Definition: main.cpp:49
Describe a mode in the program arguments.
Definition: OptionMode.h:13
bool isOptionExist(const PString &optionName) const
Say if the given option has been passed to the program.
Definition: OptionMode.cpp:210
bool getValue(T &value, const PString &optionName) const
Get the value of the option.
void parseArgument(int argc, char **argv)
Parse the arguments passed to the program.
const OptionMode & getDefaultMode() const
Get default mode.

References createOptionParser(), OptionParser::getDefaultMode(), OptionMode::getValue(), OptionMode::isOptionExist(), OptionParser::parseArgument(), and processFile().

+ Here is the call graph for this function: