--- /dev/null
+A command taking no args:
+
+ $ rbd showmapped junk
+ rbd: too many arguments
+ [1]
+
+A command taking one arg:
+
+ $ rbd info img1 junk
+ rbd: too many arguments
+ [1]
+
+A command taking two args:
+
+ $ rbd copy img1 img2 junk
+ rbd: too many arguments
+ [1]
+
+A command taking three args:
+
+ $ rbd lock remove img1 lock1 locker1 junk
+ rbd: too many arguments
+ [1]
+
+A command taking unlimited args:
+
+ $ rbd feature enable img1 layering striping exclusive-lock object-map fast-diff deep-flatten journaling junk
+ rbd: the argument for option is invalid
+ [1]
+
+ $ rbd feature disable img1 layering striping exclusive-lock object-map fast-diff deep-flatten journaling junk
+ rbd: the argument for option is invalid
+ [1]
po::positional_options_description positional_options;
positional_options.add(at::POSITIONAL_COMMAND_SPEC.c_str(),
matching_spec->size());
- if (command_spec.size() > matching_spec->size()) {
- positional_options.add(at::POSITIONAL_ARGUMENTS.c_str(), -1);
+ if (!positional_opts.options().empty()) {
+ int max_count = positional_opts.options().size();
+ if (positional_opts.options().back()->semantic()->max_tokens() > 1)
+ max_count = -1;
+ positional_options.add(at::POSITIONAL_ARGUMENTS.c_str(), max_count);
}
po::options_description global_opts;
std::cerr << "rbd: " << e.what() << std::endl;
return EXIT_FAILURE;
} catch (po::too_many_positional_options_error& e) {
- std::cerr << "rbd: too many positional arguments or unrecognized optional "
- << "argument" << std::endl;
+ std::cerr << "rbd: too many arguments" << std::endl;
+ return EXIT_FAILURE;
} catch (po::error& e) {
std::cerr << "rbd: " << e.what() << std::endl;
return EXIT_FAILURE;