1 /* $Id: metaproxy_prog.cpp,v 1.6 2006-06-10 14:29:12 adam Exp $
2 Copyright (c) 2005-2006, Index Data.
4 See the LICENSE file for details
9 #include <boost/program_options.hpp>
10 namespace po = boost::program_options;
16 #include "package.hpp"
17 #include "router_flexml.hpp"
18 #include "factory_static.hpp"
20 namespace mp = metaproxy_1;
22 int main(int argc, char **argv)
26 po::options_description desc("Allowed options");
28 ("help,h", "produce help message")
29 ("version,V", "show version")
30 ("config", po::value< std::vector<std::string> >(), "xml config")
33 po::positional_options_description p;
37 po::store(po::command_line_parser(argc, argv).
38 options(desc).positional(p).run(), vm);
41 if (vm.count("help")) {
42 std::cout << desc << "\n";
45 if (vm.count("version")) {
46 std::cout << "Metaproxy " VERSION "\n";
50 if (vm.count("config"))
52 std::vector<std::string> config_fnames =
53 vm["config"].as< std::vector<std::string> >();
55 if (config_fnames.size() != 1)
57 std::cerr << "Only one configuration must be given\n";
61 doc = xmlParseFile(config_fnames[0].c_str());
64 std::cerr << "xmlParseFile failed\n";
70 std::cerr << "No configuration given\n";
76 mp::FactoryStatic factory;
77 mp::RouterFleXML router(doc, factory);
79 pack.router(router).move();
81 catch (std::runtime_error &e) {
82 std::cerr << "std::runtime error: " << e.what() << "\n";
88 catch (po::unknown_option &e) {
89 std::cerr << e.what() << "; use --help for list of options\n";
92 catch (std::logic_error &e) {
93 std::cerr << "std::logic error: " << e.what() << "\n";
96 catch (std::runtime_error &e) {
97 std::cerr << "std::runtime error: " << e.what() << "\n";
101 std::cerr << "Unknown Exception" << std::endl;
111 * indent-tabs-mode: nil
112 * c-file-style: "stroustrup"
114 * vim: shiftwidth=4 tabstop=8 expandtab