# # # patch "commands.cc" # from [435213229eda5334477bb96e708721aa80f2f9c6] # to [6697a3fcf10ec7c0f3c5e44c0efc1c5547a354cf] # # patch "commands.hh" # from [b66907502fd4f406ad77c3f395a8a610735a44cd] # to [d17b0cdfffe5affe3c314ded94366e5255e0948e] # # patch "monotone.cc" # from [32eb1e400ae57e6d1d1ac34897d45bb98caa0f70] # to [3612544da8f7619e8dbff006f547075bc3c6ace5] # ============================================================ --- commands.cc 435213229eda5334477bb96e708721aa80f2f9c6 +++ commands.cc 6697a3fcf10ec7c0f3c5e44c0efc1c5547a354cf @@ -680,26 +680,13 @@ namespace commands } } - options::options_type command_options(args_vector const & cmdline) + options::options_type command_options(command_id const & ident) { -/* - if (cmdline.empty()) - return options::options_type(); - string name = complete_command(idx(cmdline,0)()); - if (!name.empty()) - { - return find_command(name)->opts(); - } - else - { - N(!name.empty(), - F("unknown command '%s'") % idx(cmdline, 0)); - return options::options_type(); - } -*/ - return options::options_type(); + command * cmd = find_command(ident); + return cmd->opts(); } + // XXX How does this differ from command_options()? options::options_type toplevel_command_options(command_id const & ident) { command * cmd = find_command(ident); ============================================================ --- commands.hh b66907502fd4f406ad77c3f395a8a610735a44cd +++ commands.hh d17b0cdfffe5affe3c314ded94366e5255e0948e @@ -28,7 +28,7 @@ namespace commands { command_id complete_command(args_vector const & args); int process(app_state & app, command_id const & ident, args_vector const & args); - options::options_type command_options(args_vector const & cmdline); + options::options_type command_options(command_id const & ident); options::options_type toplevel_command_options(command_id const & ident); }; ============================================================ --- monotone.cc 32eb1e400ae57e6d1d1ac34897d45bb98caa0f70 +++ monotone.cc 3612544da8f7619e8dbff006f547075bc3c6ace5 @@ -133,24 +133,20 @@ commands::command_id read_options(option options::opts::all_options().instantiate(&opts); optset.from_command_line(args); - // consume the command, and perform completion if necessary if (!opts.args.empty()) { + // There are some arguments remaining in the command line. Try first + // to see if they are a command. cmd = commands::complete_command(opts.args); I(!cmd.empty()); - } - // reparse options, now that we know what command-specific - // options are allowed. + // Reparse options now that we know what command-specific options + // are allowed. + options::options_type cmdopts = commands::command_options(cmd); + optset.reset(); + optset = (options::opts::globals() | cmdopts).instantiate(&opts); + optset.from_command_line(args, false); - options::options_type cmdopts = commands::command_options(opts.args); - optset.reset(); - - optset = (options::opts::globals() | cmdopts).instantiate(&opts); - optset.from_command_line(args, false); - - if (!opts.args.empty()) - { // Remove the command name from the arguments. It is important to // note that the first component of the identifier is always optional, // so we must take care about that here. @@ -164,8 +160,7 @@ commands::command_id read_options(option for (args_vector::size_type i = 0; i < cmd2.size(); i++) { - // Cannot enable the check below due to command name aliases. - // I(cmd2[i]().find(opts.args[i]()) == 0); + I(cmd2[i]().find(opts.args[i]()) == 0); opts.args.erase(opts.args.begin()); } }