177 static const option longopts[] = {
179 {
"schema", required_argument, NULL,
opt::Schema },
180 {
"setup", required_argument, NULL,
opt::Setup },
183 {
"debug", optional_argument, NULL,
opt::Debug },
184 {
"help", no_argument, NULL,
opt::Help },
191 std::string shortopts =
":";
192 for (
auto const& longopt: longopts) {
193 if (!longopt.name)
break;
194 if (longopt.val == 0)
continue;
195 shortopts += (char) longopt.val;
196 if (longopt.has_arg != no_argument) shortopts +=
':';
197 if (longopt.has_arg == optional_argument) shortopts +=
':';
202 error res = error::Success;
205 bool forgiving =
false;
207 ((ch = getopt_long(argc, argv, shortopts.c_str(), longopts, NULL)) != -1)
227 std::istringstream sstr(optarg);
230 std::cerr <<
"Invalid debug level: '" << optarg <<
"'" << std::endl;
231 res = error::InvalidNumber;
241 <<
"Invalid option: '" << argv[optind-1] <<
"'" << std::endl;
243 res = error::InvalidOption;
252 std::cerr <<
"Internal error: option '" << ch <<
"' not supported yet."
254 res = error::LogicError;
261 if (optind >= (
int) argc) {
262 if (!forgiving)
std::cerr <<
"Source file name is required!" << std::endl;
263 return error::MissingArgument;
266 if (optind < (
int) argc) params.
destPath = argv[optind++];
268 if (optind < (
int) argc) {
270 std::cerr <<
"Spurious arguments: '" << argv[optind] <<
"'";
271 if (optind + 1 < (
int) argc)
272 std::cerr <<
" and " << (argc - optind - 1) <<
" more";
275 return error::ExtraArguments;
then if[["$THISISATEST"==1]]
BEGIN_PROLOG could also be cerr
static constexpr const char Setup
std::string setupName
Name of the chosen setup in the GDML source.
static const unsigned int DefaultDebugLevel
static constexpr const char Schema
bool overwrite
Overwrite the output file if already present.
static constexpr const char Debug
static constexpr const char NoWrite
bool help
Print usage instructions and exit.
std::string destPath
GDML output file name.
bool validate
Ask Geant4 to validate the source.
std::string sourcePath
GDML input file name.
std::string schemaPath
URL of the schema used while writing GDML.
bool dontWrite
Do not write the output file.
unsigned int debugLevel
Debug level.
static constexpr const char Help
static constexpr const char Validate
static constexpr const char Overwrite