From 9c5ad6b64f33ea07654435e93a8b6f726894581f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 4 Apr 2015 09:27:49 +0000 Subject: Support GNU style long options. Update usage output and man page to distinguish flags from options that take a value. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5660 a436a847-0d15-0410-975c-d299462d15a1 --- src/ingen/ingen.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'src/ingen/ingen.cpp') diff --git a/src/ingen/ingen.cpp b/src/ingen/ingen.cpp index 4ee45441..12a17e99 100644 --- a/src/ingen/ingen.cpp +++ b/src/ingen/ingen.cpp @@ -64,7 +64,7 @@ static void ingen_try(bool cond, const char* msg) { if (!cond) { - cerr << "ingen: Error: " << msg << endl; + cerr << "ingen: error: " << msg << endl; delete world; exit(EXIT_FAILURE); } @@ -101,7 +101,7 @@ main(int argc, char** argv) return print_version(); } } catch (std::exception& e) { - cout << "ingen: " << e.what() << endl; + cout << "ingen: error: " << e.what() << endl; return EXIT_FAILURE; } @@ -113,8 +113,7 @@ main(int argc, char** argv) // Run engine SPtr engine_interface; if (conf.option("engine").get()) { - ingen_try(world->load_module("server"), - "Unable to load server module"); + ingen_try(world->load_module("server"), "Failed to load server module"); ingen_try(bool(world->engine()), "Unable to create engine"); world->engine()->listen(); @@ -124,8 +123,7 @@ main(int argc, char** argv) // If we don't have a local engine interface (for GUI), use network if (!engine_interface) { - ingen_try(world->load_module("client"), - "Unable to load client module"); + ingen_try(world->load_module("client"), "Failed to load client module"); #ifdef HAVE_SOCKET Client::SocketClient::register_factories(world); #endif @@ -136,9 +134,9 @@ main(int argc, char** argv) engine_interface = world->new_interface(Raul::URI(uri), client); if (!engine_interface && !conf.option("gui").get()) { - cerr << fmt("ingen: Error: Unable to create interface to `%1%'\n"); + cerr << (fmt("ingen: error: Failed to connect to `%1%'\n") % uri); delete world; - exit(EXIT_FAILURE); + return EXIT_FAILURE; } } @@ -146,19 +144,17 @@ main(int argc, char** argv) // Load GUI if requested if (conf.option("gui").get()) { - ingen_try(world->load_module("gui"), - "Unable to load GUI module"); + ingen_try(world->load_module("gui"), "Failed to load GUI module"); } // Activate the engine, if we have one if (world->engine()) { - ingen_try(world->load_module("jack"), - "Unable to load jack module"); + ingen_try(world->load_module("jack"), "Failed to load jack module"); world->engine()->activate(); } // Load a graph - if (conf.option("load").is_valid() || !conf.files().empty()) { + if (conf.option("load").is_valid()) { boost::optional parent; boost::optional symbol; @@ -175,16 +171,14 @@ main(int argc, char** argv) } } - ingen_try(bool(world->parser()), "Unable to create parser"); + ingen_try(bool(world->parser()), "Failed to create parser"); - const string path = (conf.option("load").is_valid() - ? conf.option("load").ptr() - : conf.files().front()); + const string graph = conf.option("load").ptr(); engine_interface->get(Raul::URI("ingen:/plugins")); engine_interface->get(Node::root_uri()); world->parser()->parse_file( - world, engine_interface.get(), path, parent, symbol); + world, engine_interface.get(), graph, parent, symbol); } // Set up signal handlers that will set quit_flag on interrupt -- cgit v1.2.1