X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fmetaproxy_prog.cpp;h=0bec0772d5c9137e8d62f5aef98a669ea9636198;hb=6bae168228128b1c87b5c531f559050b7e5603cf;hp=9151d0b2e2dba50bf62d470a7bcbf8a9c96cf124;hpb=79100c2ae2dac4bdde4f4d46b69e147562b4ec6c;p=metaproxy-moved-to-github.git diff --git a/src/metaproxy_prog.cpp b/src/metaproxy_prog.cpp index 9151d0b..0bec077 100644 --- a/src/metaproxy_prog.cpp +++ b/src/metaproxy_prog.cpp @@ -1,7 +1,7 @@ -/* $Id: metaproxy_prog.cpp,v 1.1 2006-03-16 10:40:59 adam Exp $ +/* $Id: metaproxy_prog.cpp,v 1.6 2006-06-10 14:29:12 adam Exp $ Copyright (c) 2005-2006, Index Data. -%LICENSE% + See the LICENSE file for details */ #include "config.hpp" @@ -25,7 +25,8 @@ int main(int argc, char **argv) { po::options_description desc("Allowed options"); desc.add_options() - ("help", "produce help message") + ("help,h", "produce help message") + ("version,V", "show version") ("config", po::value< std::vector >(), "xml config") ; @@ -35,13 +36,16 @@ int main(int argc, char **argv) po::variables_map vm; po::store(po::command_line_parser(argc, argv). options(desc).positional(p).run(), vm); - po::notify(vm); + po::notify(vm); if (vm.count("help")) { std::cout << desc << "\n"; return 1; } - + if (vm.count("version")) { + std::cout << "Metaproxy " VERSION "\n"; + return 0; + } xmlDocPtr doc = 0; if (vm.count("config")) { @@ -75,12 +79,24 @@ int main(int argc, char **argv) pack.router(router).move(); } catch (std::runtime_error &e) { - std::cout << "std::runtime error: " << e.what() << "\n"; - exit(1); + std::cerr << "std::runtime error: " << e.what() << "\n"; + std::exit(1); } xmlFreeDoc(doc); } } + catch (po::unknown_option &e) { + std::cerr << e.what() << "; use --help for list of options\n"; + std::exit(1); + } + catch (std::logic_error &e) { + std::cerr << "std::logic error: " << e.what() << "\n"; + std::exit(1); + } + catch (std::runtime_error &e) { + std::cerr << "std::runtime error: " << e.what() << "\n"; + std::exit(1); + } catch ( ... ) { std::cerr << "Unknown Exception" << std::endl; std::exit(1);