1 /* $Id: metaproxy_prog.cpp,v 1.3 2006-04-29 08:47:40 adam Exp $
2 Copyright (c) 2005-2006, Index Data.
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 ("config", po::value< std::vector<std::string> >(), "xml config")
32 po::positional_options_description p;
36 po::store(po::command_line_parser(argc, argv).
37 options(desc).positional(p).run(), vm);
40 if (vm.count("help")) {
41 std::cout << desc << "\n";
46 if (vm.count("config"))
48 std::vector<std::string> config_fnames =
49 vm["config"].as< std::vector<std::string> >();
51 if (config_fnames.size() != 1)
53 std::cerr << "Only one configuration must be given\n";
57 doc = xmlParseFile(config_fnames[0].c_str());
60 std::cerr << "xmlParseFile failed\n";
66 std::cerr << "No configuration given\n";
72 mp::FactoryStatic factory;
73 mp::RouterFleXML router(doc, factory);
75 pack.router(router).move();
77 catch (std::runtime_error &e) {
78 std::cout << "std::runtime error: " << e.what() << "\n";
84 catch (po::unknown_option &e) {
85 std::cerr << e.what() << "; use --help for list of options\n";
88 catch (std::logic_error &e) {
89 std::cerr << "std::logic error: " << e.what() << "\n";
92 catch (std::runtime_error &e) {
93 std::cout << "std::runtime error: " << e.what() << "\n";
97 std::cerr << "Unknown Exception" << std::endl;
107 * indent-tabs-mode: nil
108 * c-file-style: "stroustrup"
110 * vim: shiftwidth=4 tabstop=8 expandtab