@@ -45,7 +45,7 @@ memcached_return_t memcat(const client_options &opt, memcached_st *memc, const c
45
45
if (verbose) {
46
46
*ref << " value: " ;
47
47
}
48
-
48
+
49
49
ref->write (val, len);
50
50
51
51
if (verbose || !opt.isset (" file" )) {
@@ -68,7 +68,8 @@ int main(int argc, char *argv[]) {
68
68
opt.add (def);
69
69
}
70
70
opt.add (" flags" , ' F' , no_argument, " Display key flags, too." );
71
- opt.add (" file" , ' f' , required_argument, " Output to file instead of standard output." );
71
+ opt.add (" file" , ' f' , optional_argument, " Output to file instead of standard output."
72
+ " \n\t\t # NOTE: defaults to <key> if no argument was provided." );
72
73
73
74
char **argp = nullptr ;
74
75
if (!opt.parse (argc, argv, &argp)) {
@@ -99,8 +100,9 @@ int main(int argc, char *argv[]) {
99
100
for (auto arg = argp; *arg; ++arg) {
100
101
auto key = *arg;
101
102
if (*key) {
103
+ char *file = opt.isset (" file" ) ? (opt.argof (" file" ) ?: key) : nullptr ;
102
104
std::ofstream fstream{};
103
- std::ostream *ostream = check_ostream (opt, opt. argof ( " file" ) , fstream);
105
+ std::ostream *ostream = check_ostream (opt, file, fstream);
104
106
105
107
if (!check_return (opt, memc, key, memcat (opt, &memc, key, ostream))) {
106
108
exit_code = EXIT_FAILURE;
0 commit comments