Directory: | ./ |
---|---|
File: | tmp_project/PhoenixTex2Html/src/tools/PSRC_SPLIT_PTEX/main.cpp |
Date: | 2025-03-24 18:12:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 29 | 29 | 100.0% |
Branches: | 52 | 52 | 100.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /*************************************** | ||
2 | Auteur : Pierre Aubert | ||
3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
4 | Licence : CeCILL-C | ||
5 | ****************************************/ | ||
6 | |||
7 | #include "OptionParser.h" | ||
8 | |||
9 | #include "psrc_split_lib.h" | ||
10 | |||
11 | ///Create the OptionParser of this program | ||
12 | /** @return OptionParser of this program | ||
13 | */ | ||
14 | 65 | OptionParser createOptionParser(){ | |
15 |
2/2✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
|
65 | OptionParser parser(true, __PROGRAM_VERSION__); |
16 |
2/2✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
|
65 | parser.setExampleLongOption("phoenix_psrcsplittex --input=fileInput.cpp --output=output.ptex --platex"); |
17 |
2/2✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
|
65 | parser.setExampleShortOption("phoenix_psrcsplittex -i fileInput.cpp -o output.ptex -p"); |
18 | |||
19 |
4/4✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
✓ Branch 7 taken 65 times.
✓ Branch 10 taken 65 times.
|
65 | parser.addOption("input", "i", OptionType::FILENAME, true, "name of the input file (source, c, cpp, cmake, py, cu)"); |
20 | |||
21 |
2/2✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
|
65 | PPath defaultOutputFile("./output.txt"); |
22 |
5/5✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
✓ Branch 7 taken 65 times.
✓ Branch 10 taken 65 times.
✓ Branch 13 taken 65 times.
|
65 | parser.addOption("output", "o", defaultOutputFile, "output file to be generated"); |
23 | |||
24 |
4/4✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
✓ Branch 7 taken 65 times.
✓ Branch 10 taken 65 times.
|
65 | parser.addOption("keepcomment", "k", OptionType::NONE, false, "keep the comment of the targeted language"); |
25 |
4/4✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
✓ Branch 7 taken 65 times.
✓ Branch 10 taken 65 times.
|
65 | parser.addOption("keeptex", "t", OptionType::NONE, false, "keep the ptex comment in the output file"); |
26 |
4/4✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
✓ Branch 7 taken 65 times.
✓ Branch 10 taken 65 times.
|
65 | parser.addOption("removefirstcomment", "f", OptionType::NONE, false, "remove the first comment of the file (can be the Licence or whatever)"); |
27 |
4/4✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
✓ Branch 7 taken 65 times.
✓ Branch 10 taken 65 times.
|
65 | parser.addOption("platex", "p", OptionType::NONE, false, "activate platex mode (add begin and end around code part)"); |
28 | |||
29 | 130 | return parser; | |
30 | 65 | } | |
31 | |||
32 | 65 | int main(int argc, char** argv){ | |
33 |
1/1✓ Branch 1 taken 65 times.
|
65 | OptionParser parser = createOptionParser(); |
34 |
1/1✓ Branch 1 taken 65 times.
|
65 | parser.parseArgument(argc, argv); |
35 | |||
36 |
1/1✓ Branch 1 taken 65 times.
|
65 | const OptionMode & defaultMode = parser.getDefaultMode(); |
37 |
1/1✓ Branch 1 taken 65 times.
|
65 | PPath inputFile; |
38 |
2/2✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
|
65 | defaultMode.getValue(inputFile, "input"); |
39 | |||
40 |
2/2✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
|
65 | PPath outputDir("."); |
41 |
2/2✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
|
65 | defaultMode.getValue(outputDir, "output"); |
42 | |||
43 | 65 | bool keepComment(false), keepTex(false), removefirstcomment(false), isPlatexMode(false); | |
44 |
2/2✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
|
65 | keepComment = defaultMode.isOptionExist("keepcomment"); |
45 |
2/2✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
|
65 | keepTex = defaultMode.isOptionExist("keeptex"); |
46 |
2/2✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
|
65 | removefirstcomment = defaultMode.isOptionExist("removefirstcomment"); |
47 |
2/2✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
|
65 | isPlatexMode = defaultMode.isOptionExist("platex"); |
48 | |||
49 |
1/1✓ Branch 1 taken 65 times.
|
65 | bool b(processFile(outputDir, inputFile, keepComment, keepTex, removefirstcomment, isPlatexMode)); |
50 | 65 | return b - 1; | |
51 | 65 | } | |
52 | |||
53 | |||
54 | |||
55 | |||
56 |