-# define opt_flag(s, a, h) opt_flag_ex(#s, s, a, h)
-# define opt_flag_ex(n, v, a, h) \
- [static_cast<int>(flag::v)-first_flag] = {n, a, &flags.v, static_cast<int>(flag::v)}; \
- help[static_cast<int>(flag::v)-first_flag] = h
-
-# define opt_data(s, a, h) opt_data_ex(#s, s, a, h)
-# define opt_data_ex(n, v, a, h) \
- [static_cast<int>(flag::v)-first_flag] = {n, a, nullptr, static_cast<int>(flag::v)}; \
- help[static_cast<int>(flag::v)-first_flag] = h
-
- avail opt_flag( absolute, no_argument, "Use absolute path names.");
- avail opt_flag( flush, no_argument, "Flush the server(s).");
- avail opt_flag_ex("add", add_cmd, no_argument, "Perform ADD operations.");
- avail opt_flag( buffer, no_argument, "Buffer requests.");
- avail opt_data( concurrency,required_argument,"Level of concurrency.");
- avail opt_flag( flags, no_argument, "Print or set associated flags for key(s).");
- avail opt_data( hash, required_argument,"Select key hash.");
- avail opt_data( load, required_argument,"Initial load.");
- avail opt_flag_ex("tcp-nodelay",tcp_nodelay,no_argument, "Disable Nagle's algorithm.");
- avail opt_data( query, no_argument, "Query arguments.");
- avail opt_flag_ex("replace", replace_cmd,no_argument, "Perform REPLACE operations.");
- avail opt_flag_ex("set", set_cmd, no_argument, "Perform SET operations.");
- avail opt_flag( udp, no_argument, "Use UDP.");
- avail opt_flag( version, no_argument, "Print program version.");
- avail opt_flag( analyze, no_argument, "Analyze the server's statistics.");
- avail opt_flag( binary, no_argument, "Use the binary memcached protocol.");
- avail opt_flag( debug, no_argument, "Print output useful only for debugging.");
- avail opt_data( expire, required_argument,"Set associated expiry time for key(s).");
- avail opt_data( file, required_argument,"File to save to or read from.");
- avail opt_flag( help, no_argument, "Print this help.");
- avail opt_flag_ex("non-block", non_block, no_argument, "Use non blocking connections.");
- avail opt_data( password, required_argument,"SASL password.");
- avail opt_flag( quiet, no_argument, "Print no output, not even errors.");
- avail opt_data( repeat, required_argument,"Repeat operation n times.");
- avail opt_data( servers, required_argument,"List of servers to connect to.");
- avail opt_data( test, required_argument,"Test to perform.");
- avail opt_data( username, required_argument,"SASL username.");
- avail opt_flag( verbose, no_argument, "Print more informational output.");
- avail opt_flag( zero, no_argument, "Zero.");
-
- long_opts.reserve(f.size() + 1);
- short_opts.reserve(f.size() * 3);
-
- for (auto o : f) {
- auto &opt = avail[static_cast<int>(o)-first_flag];
-
- long_opts.push_back(opt);
- short_opts.push_back(opt.val);
-
- for (int i = 0; i < opt.has_arg; ++i) {
- short_opts.push_back(':');
- }
- }