| 93 | }; |
| 94 | |
| 95 | int main(int argc, char **argv) { |
| 96 | std::string address("127.0.0.1:5672/examples"); |
| 97 | std::string user; |
| 98 | std::string password; |
| 99 | bool reconnect = false; |
| 100 | int message_count = 100; |
| 101 | example::options opts(argc, argv); |
| 102 | |
| 103 | opts.add_value(address, 'a', "address", "connect and send to URL", "URL"); |
| 104 | opts.add_value(user, 'u', "user", "authenticate as USER", "USER"); |
| 105 | opts.add_value(password, 'p', "password", "authenticate with PASSWORD", "PASSWORD"); |
| 106 | opts.add_flag(reconnect, 'r', "reconnect", "reconnect on connection failure"); |
| 107 | opts.add_value(message_count, 'm', "messages", "send COUNT messages", "COUNT"); |
| 108 | |
| 109 | try { |
| 110 | opts.parse(); |
| 111 | |
| 112 | simple_send send(address, user, password, reconnect, message_count); |
| 113 | proton::container(send).run(); |
| 114 | |
| 115 | return 0; |
| 116 | } catch (const example::bad_option& e) { |
| 117 | std::cout << opts << std::endl << e.what() << std::endl; |
| 118 | } catch (const std::exception& e) { |
| 119 | std::cerr << e.what() << std::endl; |
| 120 | } |
| 121 | |
| 122 | return 1; |
| 123 | } |