mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 17:20:04 +00:00
Clean up program_options printings
This commit is contained in:
@@ -63,7 +63,7 @@ void print_version()
|
|||||||
std::cerr << "IfcOpenShell " << IfcSchema::Identifier << " IfcConvert " << IFCOPENSHELL_VERSION << std::endl;
|
std::cerr << "IfcOpenShell " << IfcSchema::Identifier << " IfcConvert " << IFCOPENSHELL_VERSION << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_usage()
|
void print_usage(bool suggest_help = true)
|
||||||
{
|
{
|
||||||
std::cerr << "Usage: IfcConvert [options] <input.ifc> [<output>]" << "\n"
|
std::cerr << "Usage: IfcConvert [options] <input.ifc> [<output>]" << "\n"
|
||||||
<< "\n"
|
<< "\n"
|
||||||
@@ -77,25 +77,16 @@ void print_usage()
|
|||||||
<< " .xml XML Property definitions and decomposition tree" << "\n"
|
<< " .xml XML Property definitions and decomposition tree" << "\n"
|
||||||
<< " .svg SVG Scalable Vector Graphics (2D floor plan)" << "\n"
|
<< " .svg SVG Scalable Vector Graphics (2D floor plan)" << "\n"
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< "If no output filename given, <input>." + DEFAULT_EXTENSION + " will be used as the output file.\n"
|
<< "If no output filename given, <input>." + DEFAULT_EXTENSION + " will be used as the output file.\n";
|
||||||
<< "\n"
|
if (suggest_help) {
|
||||||
<< "Run 'IfcConvert --help' for more information." << std::endl;
|
std::cerr << "\nRun 'IfcConvert --help' for more information.";
|
||||||
|
}
|
||||||
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_options(
|
void print_options(const boost::program_options::options_description& options)
|
||||||
const boost::optional<boost::program_options::options_description>& generic_options,
|
|
||||||
const boost::optional<boost::program_options::options_description>& geom_options,
|
|
||||||
const boost::optional<boost::program_options::options_description>& serialization_options)
|
|
||||||
{
|
{
|
||||||
if (generic_options) {
|
std::cerr << "\n" << options;
|
||||||
std::cerr << "\nCommand line options\n" << generic_options;
|
|
||||||
}
|
|
||||||
if (geom_options) {
|
|
||||||
std::cerr << "\nGeometry options\n" << geom_options;
|
|
||||||
}
|
|
||||||
if (serialization_options) {
|
|
||||||
std::cerr << "\nSerialization options\n" << serialization_options;
|
|
||||||
}
|
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +103,7 @@ static std::stringstream log_stream;
|
|||||||
void write_log();
|
void write_log();
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
boost::program_options::options_description generic_options;
|
boost::program_options::options_description generic_options("Command line options");
|
||||||
generic_options.add_options()
|
generic_options.add_options()
|
||||||
("help,h", "display usage information")
|
("help,h", "display usage information")
|
||||||
("version", "display version information")
|
("version", "display version information")
|
||||||
@@ -125,7 +116,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
std::vector<std::string> entity_vector, names;
|
std::vector<std::string> entity_vector, names;
|
||||||
double deflection_tolerance;
|
double deflection_tolerance;
|
||||||
boost::program_options::options_description geom_options;
|
boost::program_options::options_description geom_options("Geometry options");
|
||||||
geom_options.add_options()
|
geom_options.add_options()
|
||||||
("plan",
|
("plan",
|
||||||
"Specifies whether to include curves in the output result. Typically "
|
"Specifies whether to include curves in the output result. Typically "
|
||||||
@@ -189,7 +180,7 @@ int main(int argc, char** argv) {
|
|||||||
"Sets the deflection tolerance of the mesher, 1e-3 by default if not specified.");
|
"Sets the deflection tolerance of the mesher, 1e-3 by default if not specified.");
|
||||||
|
|
||||||
std::string bounds;
|
std::string bounds;
|
||||||
boost::program_options::options_description serializer_options;
|
boost::program_options::options_description serializer_options("Serialization options");
|
||||||
serializer_options.add_options()
|
serializer_options.add_options()
|
||||||
("bounds", boost::program_options::value<std::string>(&bounds),
|
("bounds", boost::program_options::value<std::string>(&bounds),
|
||||||
"Specifies the bounding rectangle, for example 512x512, to which the "
|
"Specifies the bounding rectangle, for example 512x512, to which the "
|
||||||
@@ -237,8 +228,8 @@ int main(int argc, char** argv) {
|
|||||||
if (vmap.count("version")) {
|
if (vmap.count("version")) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (vmap.count("help")) {
|
} else if (vmap.count("help")) {
|
||||||
print_usage();
|
print_usage(false);
|
||||||
print_options(generic_options, geom_options, serializer_options);
|
print_options(generic_options.add(geom_options).add(serializer_options));
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!vmap.count("input-file")) {
|
} else if (!vmap.count("input-file")) {
|
||||||
std::cerr << "[Error] Input file not specified" << std::endl;
|
std::cerr << "[Error] Input file not specified" << std::endl;
|
||||||
@@ -246,7 +237,7 @@ int main(int argc, char** argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
} else if (vmap.count("include") && vmap.count("exclude")) {
|
} else if (vmap.count("include") && vmap.count("exclude")) {
|
||||||
std::cerr << "[Error] --include and --exclude can not be specified together" << std::endl;
|
std::cerr << "[Error] --include and --exclude can not be specified together" << std::endl;
|
||||||
print_options(boost::none, geom_options, boost::none);
|
print_options(geom_options);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +268,7 @@ int main(int argc, char** argv) {
|
|||||||
bounding_height = h;
|
bounding_height = h;
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "[Error] Invalid use of --bounds" << std::endl;
|
std::cerr << "[Error] Invalid use of --bounds" << std::endl;
|
||||||
print_options(boost::none, boost::none, serializer_options);
|
print_options(serializer_options);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user