{
GetOpt getopt;
getopt.add_option('v', "verbose", verbose, GetOpt::NO_ARG);
+ getopt.add_argument("url", url, GetOpt::REQUIRED_ARG);
getopt(argc, argv);
-
- const vector<string> &args = getopt.get_args();
- if(args.empty())
- throw usage_error("No URL");
-
- url = args.front();
}
int HttpGet::main()
server_sock(0),
sock(0)
{
+ string host_name;
+
GetOpt getopt;
getopt.add_option('6', "ipv6", ipv6, GetOpt::NO_ARG);
getopt.add_option('l', "listen", listen, GetOpt::NO_ARG);
+ getopt.add_argument("host", host_name, GetOpt::REQUIRED_ARG);
getopt(argc, argv);
- const vector<string> &args = getopt.get_args();
- if(args.empty())
- throw usage_error("host argument missing");
-
- RefPtr<Net::SockAddr> addr = Net::resolve(args.front(), (ipv6 ? Net::INET6 : Net::INET));
+ RefPtr<Net::SockAddr> addr = Net::resolve(host_name, (ipv6 ? Net::INET6 : Net::INET));
if(!listen)
{
sock = new Net::StreamSocket(addr->get_family());