# # # patch "option.cc" # from [7cbfe2a7b498d4b39f0509a71ce3573025362a02] # to [1a6f3a3b3ba2956b1763679171d2deb681bb9964] # # patch "option.hh" # from [4b8b3b06e05e716358a3da600f0c0a948104af8c] # to [eccc4b6c4119657eda8e4a729ba6106562bb8ca4] # # patch "options_list.hh" # from [d2a0ffef99824aa91354c46c7dbbb20e7cd5f815] # to [6eebcbfd1f4bf20fe86867458e7425fd74d0090b] # # patch "tests/default_command_options/__driver__.lua" # from [524306e088768186ee550179e9cd8bebd3b7fec0] # to [08b5967edd5344aac720941c534e1426e872d13c] # # patch "tests/default_command_options/default_options.lua" # from [c66ceeb9cfcd88be99aa2de5c9d5445e1046a3cc] # to [e5574902b08b2259b7e7c46f0b90e658287b3d3d] # ============================================================ --- option.cc 7cbfe2a7b498d4b39f0509a71ce3573025362a02 +++ option.cc 1a6f3a3b3ba2956b1763679171d2deb681bb9964 @@ -98,6 +98,8 @@ concrete_option::concrete_option(char co I((!longname.empty() || !shortname.empty()) || cancelname.empty()); // If an option has a name (ie, can be set), it must have a setter function I(set || (longname.empty() && shortname.empty())); + // If an option can be canceled, it must have a resetter function + I(reset || cancelname.empty()); has_arg = arg; setter = set; resetter = reset; ============================================================ --- option.hh 4b8b3b06e05e716358a3da600f0c0a948104af8c +++ option.hh eccc4b6c4119657eda8e4a729ba6106562bb8ca4 @@ -77,7 +77,7 @@ namespace option { bad_arg_internal(std::string const & str = ""); }; - // Split a "long,s" option name into long and short names. + // Split a "long,s/cancel" option name into long and short names. void splitname(char const * from, std::string & name, std::string & n, std::string & cancelname); // An option that can be set and reset. ============================================================ --- options_list.hh d2a0ffef99824aa91354c46c7dbbb20e7cd5f815 +++ options_list.hh 6eebcbfd1f4bf20fe86867458e7425fd74d0090b @@ -48,12 +48,12 @@ * * * Option Strings - * Options can have a long name, a short name, and a 'reset' name. - * The long and short names work as reasonably expected, the make - * the function body in the '#ifdef option_bodies' get run. The - * 'reset' name is slightly different, it makes the optset that - * the option belongs to get reset. This means that if you have - * several related options in the same optset, you probably *don't* + * + * Options can have a long name, a short name, and a 'reset' name. The + * long and short names run the function body in the '#ifdef + * option_bodies'. The 'reset' name is slightly different, it makes the + * optset that the option belongs to get reset. This means that if you + * have several related options in the same optset, you probably *don't* * want to specify a reset name for any of them. * * If you want an option to belong to an optset and also be resettable, @@ -111,7 +111,7 @@ void set_simple_option(std::set # define SIMPLE_OPTION_BODY(name) #endif /* - * This is a 'magic' option, and Does The Right Thing based on it's data type: + * This is a 'magic' option, and Does The Right Thing based on its data type: * * If it's a bool, it will be true if the option is given and false if * not given (or reset), and will not take an argument. * * If it's a string or vocab type, it will be set to the argument if ============================================================ --- tests/default_command_options/__driver__.lua 524306e088768186ee550179e9cd8bebd3b7fec0 +++ tests/default_command_options/__driver__.lua 08b5967edd5344aac720941c534e1426e872d13c @@ -1,13 +1,24 @@ +-- Demonstrate that get_default_command_options works, and that +-- command line options override it. mtn_setup() check(get("default_options.lua")) -check(mtn("version", "--full"), 0, true, false) +check(mtn("version", "--no-verbose"), 0, true, false) +rename("stdout", "normalversion") + +check(mtn("version", "--verbose"), 0, true, false) rename("stdout", "fullversion") check(mtn("version", "--rcfile=default_options.lua"), 0, true, false) check(samefile("stdout", "fullversion")) +check(mtn("version", "--verbose", "--no-verbose"), 0, true, false) +check(samefile("stdout", "normalversion")) + +check(mtn("version", "--rcfile=default_options.lua", "--no-verbose"), 0, true, false) +check(samefile("stdout", "normalversion")) + check(mtn("status", "--rcfile=default_options.lua"), 1, false, false) ============================================================ --- tests/default_command_options/default_options.lua c66ceeb9cfcd88be99aa2de5c9d5445e1046a3cc +++ tests/default_command_options/default_options.lua e5574902b08b2259b7e7c46f0b90e658287b3d3d @@ -2,7 +2,7 @@ function get_default_command_options(com function get_default_command_options(command) local default_opts = {} if (command[1] == "version") then - table.insert(default_opts, "--full") + table.insert(default_opts, "--verbose") end -- should trigger an invalid option error if (command[1] == "status") then