Skip to content

Commit

Permalink
Merge pull request #3580 from igneus/fix_resource_path_long_opt
Browse files Browse the repository at this point in the history
Fix resource path long option
  • Loading branch information
lpugin authored Jan 25, 2024
2 parents 3a637dd + 985137d commit 80b0d3e
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions tools/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ bool optionExists(const std::string &option, int argc, char **argv, std::string
return false;
}

#define OPTION_TO_GETOPT(opt, has_arg) \
{ \
vrv::FromCamelCase(opt.GetKey()).c_str(), has_arg, 0, opt.GetShortOption() \
}

int main(int argc, char **argv)
{
std::string infile;
Expand All @@ -89,26 +94,27 @@ int main(int argc, char **argv)
// The fonts will be loaded later with Resources::InitFonts()
vrv::Toolkit toolkit(false);

vrv::Options *options = toolkit.GetOptionsObj();

static struct option base_options[] = { //
{ "all-pages", no_argument, 0, 'a' }, //
{ "input-from", required_argument, 0, 'f' }, //
{ "help", required_argument, 0, 'h' }, //
{ "log-level", required_argument, 0, 'l' }, //
{ "outfile", required_argument, 0, 'o' }, //
{ "page", required_argument, 0, 'p' }, //
{ "resources", required_argument, 0, 'r' }, //
{ "scale", required_argument, 0, 's' }, //
{ "output-to", required_argument, 0, 't' }, //
{ "version", no_argument, 0, 'v' }, //
{ "xml-id-seed", required_argument, 0, 'x' }, //
OPTION_TO_GETOPT(options->m_allPages, no_argument), //
OPTION_TO_GETOPT(options->m_inputFrom, required_argument), //
OPTION_TO_GETOPT(options->m_help, required_argument), //
OPTION_TO_GETOPT(options->m_logLevel, required_argument), //
OPTION_TO_GETOPT(options->m_outfile, required_argument), //
OPTION_TO_GETOPT(options->m_page, required_argument), //
OPTION_TO_GETOPT(options->m_resourcePath, required_argument), //
OPTION_TO_GETOPT(options->m_scale, required_argument), //
OPTION_TO_GETOPT(options->m_outputTo, required_argument), //
OPTION_TO_GETOPT(options->m_version, no_argument), //
OPTION_TO_GETOPT(options->m_xmlIdSeed, required_argument), //
// standard input - long options only or - as filename
{ "stdin", no_argument, 0, 'z' }, //
{ 0, 0, 0, 0 }
};

int baseSize = sizeof(base_options) / sizeof(option);

vrv::Options *options = toolkit.GetOptionsObj();
const vrv::MapOfStrOptions *params = options->GetItems();
int mapSize = (int)params->size();

Expand Down

0 comments on commit 80b0d3e

Please sign in to comment.