44 int main(
int argc,
char *argv[]){
49 for (
int arg = 1; arg != argc; ++arg) {
54 else if ((val ==
"--src-dir" || val ==
"-s") && arg+1 != argc) {
55 input_dir = argv[++arg];
57 else if ((val ==
"--output" || val ==
"-o") && arg+1 != argc) {
58 output_file = argv[++arg];
60 else if ((val ==
"--regex" || val ==
"-r") ) {
62 regex_file = argv[++arg];
65 f.open(regex_file.c_str(),std::ios::out|std::ios::trunc);
73 else if (val ==
"--help" || val ==
"-h") {
74 std::cout <<
"usage: " << argv[0]
75 <<
" [-erhV] [-s <input_dir>] [-o <output_file>]\n"
76 <<
" -r, --regex <regex_file>\t"
77 <<
"List of used regexes.\n"
79 <<
"Expands all tags due to their super-tags."
80 <<
"Useful to debug schema markup.\n"
81 <<
" -h, --help\t\t\t"
82 <<
"Shows this usage message.\n"
83 <<
" -s, --src-dir <input_dir>\t"
84 <<
"Select the input directory.\n"
85 <<
" -o, --output <output_file>\t"
86 <<
"Select the output file.\n"
87 <<
" -V, --version\t\t\t"
88 <<
"Version of tool\n";
90 }
else if (val ==
"--version" || val ==
"-V") {
91 std::cout <<
"Battle for Wesnoth schema generator tool, version "
94 }
else if (val ==
"--expand" || val ==
"-e") {
98 if(input_dir.empty()){
99 std::cout <<
"No input was selected. Processing \"./src\"\n";
107 std::vector<std::string> files;
108 std::vector<std::string> dirs;
113 if (files.empty() && dirs.empty()){
114 std::cout <<
"Some problem with input directory "
116 <<
"No files found\n";
120 while (!dirs.empty()){
126 files.push_back(input_dir);
133 for (;i != files.end(); ++
i){
150 std::cout <<
"Processed " << counter <<
" files in " << input_dir <<
"\n";
158 std::cout <<
"There are some errors\n";
162 std::cout <<
"Continue with errors? Y/N ";
165 const char *
r = strchr(
"yYnN",c);
167 std::cout <<
"Please, choose your answer " << std::endl;
170 if (c ==
'n' || c==
'N'){
171 std::cout <<
"I'll take that as a NO" << std::endl;
174 if (c ==
'y' || c==
'Y'){
175 std::cout <<
"I'll take that as a Yes" << std::endl;
187 std::cout <<
"Schema written to "<< output_file <<
"\n";
void test_regex(std::ostream &f)
Writes to the file regex templates list.
bool parse_source()
Parses file line-by-line, checking every line to open WIKI block Please, notice that main input work ...
int main(int argc, char *argv[])
Parses the command line.
This file contains sourceparser object, collecting annotations and building a tag tree...
GLuint const GLfloat * val
bool save_schema()
Saves tag tree to schema file.
void set_input(const std::string &s)
void expand()
Expands all tags.
std::string base_name(const std::string &file)
Returns the base filename of a file, with directory name stripped.
const class_error_container & see_errors() const
Grants access to error container.
bool is_directory(const std::string &fname)
Returns true if the given file is a directory.
void get_files_in_dir(const std::string &dir, std::vector< std::string > *files, std::vector< std::string > *dirs=nullptr, file_name_option mode=FILE_NAME_ONLY, file_filter_option filter=NO_FILTER, file_reorder_option reorder=DONT_REORDER, file_tree_checksum *checksum=nullptr)
Populates 'files' with all the files and 'dirs' with all the directories in dir.
bool is_empty() const
Checks, if container is empty.
Declarations for File-IO.
void set_output(const std::string &s)
GLdouble GLdouble GLdouble r
void print_errors(std::ostream &s) const
Prints errors to output stream.
bool file_exists(const std::string &name)
Returns true if a file or directory with such name already exists.
GLsizei const GLcharARB ** string