-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
TclapOutput.h
106 lines (85 loc) · 3 KB
/
TclapOutput.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
This file is part of the DSP-Crowd project
https://www.dsp-crowd.com
Author(s):
- Johannes Natter, [email protected]
File created on 08.01.2020
Copyright (C) 2020 Authors and www.dsp-crowd.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TCLAP_OUTPUT_H
#define TCLAP_OUTPUT_H
#include <tclap/CmdLine.h>
// http://tclap.sourceforge.net/
class TclapOutput : public TCLAP::StdOutput
{
public:
virtual void usage(TCLAP::CmdLineInterface& c)
{
std::string tmp;
std::cout << std::endl << dPackageName << std::endl;
std::cout << "Application: " << dAppName << std::endl << std::endl;
std::cout << "Usage: " << dAppName << " [OPTION]" << std::endl;
std::cout << std::endl;
std::cout << "Required" << std::endl;
std::cout << std::endl;
std::list<TCLAP::Arg*> args = c.getArgList();
for (TCLAP::ArgListIterator it = args.begin(); it != args.end(); it++) {
tmp = (*it)->longID();
if ((*it)->isRequired() && tmp.find(",") != std::string::npos) {
tmp.erase(2, tmp.find(",") - 2);
std::cout << std::setw(2) << " ";
std::cout << std::setw(35) << std::left << tmp;
tmp = (*it)->getDescription();
tmp.erase(0, 12);
std::cout << tmp << std::endl;
}
}
for (TCLAP::ArgListIterator it = args.begin(); it != args.end(); it++) {
tmp = (*it)->longID();
if ((*it)->isRequired() && tmp.find(",") == std::string::npos) {
std::cout << std::setw(7) << " ";
std::cout << std::setw(30) << std::left << tmp;
tmp = (*it)->getDescription();
tmp.erase(0, 12);
std::cout << tmp << std::endl;
}
}
std::cout << std::endl;
std::cout << "Optional" << std::endl;
std::cout << std::endl;
for (TCLAP::ArgListIterator it = args.begin(); it != args.end(); it++) {
tmp = (*it)->longID();
if (!(*it)->isRequired() && tmp.find(",") != std::string::npos) {
tmp.erase(2, tmp.find(",") - 2);
std::cout << std::setw(2) << " ";
std::cout << std::setw(35) << std::left << tmp;
std::cout << (*it)->getDescription() << std::endl;
}
}
for (TCLAP::ArgListIterator it = args.begin(); it != args.end(); it++) {
tmp = (*it)->longID();
if (!(*it)->isRequired() && tmp.find(",") == std::string::npos) {
std::cout << std::setw(7) << " ";
std::cout << std::setw(30) << std::left << tmp;
std::cout << (*it)->getDescription() << std::endl;
}
}
std::cout << std::endl;
printAppCommands();
}
private:
virtual void printAppCommands()
{
}
};
#endif