Merge pull request #1343 from ArchimedesPi/quiet-mode

Implement quiet mode
master
Marius Kintel 2015-05-14 22:14:21 -04:00
commit 52f5fe2e92
3 changed files with 15 additions and 5 deletions

View File

@ -800,6 +800,7 @@ int main(int argc, char **argv)
("projection", po::value<string>(), "(o)rtho or (p)erspective when exporting png")
("colorscheme", po::value<string>(), "colorscheme")
("debug", po::value<string>(), "special debug info")
("quiet,q", "quiet mode (don't print anything *except* errors)")
("o,o", po::value<string>(), "out-file")
("s,s", po::value<string>(), "stl-file")
("x,x", po::value<string>(), "dxf-file")
@ -835,6 +836,9 @@ int main(int argc, char **argv)
OpenSCAD::debug = vm["debug"].as<string>();
PRINTB("Debug on. --debug=%s",OpenSCAD::debug);
}
if (vm.count("quiet")) {
OpenSCAD::quiet = true;
}
if (vm.count("help")) help(argv[0]);
if (vm.count("version")) version();
if (vm.count("info")) arg_info = true;

View File

@ -12,6 +12,7 @@ std::list<std::string> print_messages_stack;
OutputHandlerFunc *outputhandler = NULL;
void *outputhandler_data = NULL;
std::string OpenSCAD::debug("");
bool OpenSCAD::quiet = false;
boost::circular_buffer<std::string> lastmessages(5);
@ -63,10 +64,12 @@ void PRINT_NOCACHE(const std::string &msg)
else lastmessages.push_back(msg);
}
if (!outputhandler) {
fprintf(stderr, "%s\n", msg.c_str());
} else {
outputhandler(msg, outputhandler_data);
if (!OpenSCAD::quiet || boost::starts_with(msg, "ERROR")) {
if (!outputhandler) {
fprintf(stderr, "%s\n", msg.c_str());
} else {
outputhandler(msg, outputhandler_data);
}
}
}

View File

@ -12,7 +12,10 @@ inline char * _( const char * msgid ) { return gettext( msgid ); }
typedef void (OutputHandlerFunc)(const std::string &msg, void *userdata);
extern OutputHandlerFunc *outputhandler;
extern void *outputhandler_data;
namespace OpenSCAD { extern std::string debug; }
namespace OpenSCAD {
extern std::string debug;
extern bool quiet;
}
void set_output_handler(OutputHandlerFunc *newhandler, void *userdata);