# # # patch "cmd_automate.cc" # from [5ed92bb941b4c560f73a7c5b86899235e40b3f5c] # to [c87d0da197f80d81c5d6f2cab90a8a706e354da9] # # patch "cmd_db.cc" # from [ee7051945ff187140d9890ac10fd8c84db6171b8] # to [ad1327e9dc562190abdc869bc6e316a381a1dd90] # # patch "commands.cc" # from [6a8a053c6c687de7aeb91bb53f5beba7a7358c33] # to [3f88d20ac14273403ee6fe76031cf3bc23f6214a] # # patch "simplestring_xform.cc" # from [4d9df66d29c1e2b1ec4ef1717b271de71fd3d941] # to [f7e8187b4e03fb0a485ef30c3fe435811cdd18ae] # # patch "simplestring_xform.hh" # from [a3d2b3c5201493b1609578d624070636688c989e] # to [89cdfdba53791a234710fe3486538b6c32399177] # ============================================================ --- cmd_automate.cc 5ed92bb941b4c560f73a7c5b86899235e40b3f5c +++ cmd_automate.cc c87d0da197f80d81c5d6f2cab90a8a706e354da9 @@ -11,6 +11,7 @@ #include #include "cmd.hh" +#include "simplestring_xform.hh" using std::istream; using std::make_pair; @@ -35,6 +36,8 @@ namespace automation { first = false; automations = new map; } + + name = replace_underscores_with_dashes(name); automations->insert(make_pair(name, this)); } automate::~automate() {} @@ -45,7 +48,17 @@ find_automation(utf8 const & name, strin { map::const_iterator i = automation::automations->find(name()); + + // maintain support for both _ and - style command names for a while + // FIXME: should we issue a warning about incorrect usage here? + if (i == automation::automations->end()) + { + string other_name = replace_underscores_with_dashes(name); + i = automation::automations->find(other_name); + } + + if (i == automation::automations->end()) throw usage(root_cmd_name); else return *(i->second); ============================================================ --- cmd_db.cc ee7051945ff187140d9890ac10fd8c84db6171b8 +++ cmd_db.cc ad1327e9dc562190abdc869bc6e316a381a1dd90 @@ -51,14 +51,14 @@ CMD(db, N_("database"), "load\n" "migrate\n" "execute\n" - "kill_rev_locally ID\n" - "kill_branch_certs_locally BRANCH\n" - "kill_tag_locally TAG\n" + "kill-rev-locally ID\n" + "kill-branch-certs-locally BRANCH\n" + "kill-tag-locally TAG\n" "check\n" "changesetify\n" "rosterify\n" - "regenerate_caches\n" - "set_epoch BRANCH EPOCH\n"), + "regenerate-caches\n" + "set-epoch BRANCH EPOCH\n"), N_("manipulate database state"), options::opts::drop_attr) { @@ -82,7 +82,7 @@ CMD(db, N_("database"), build_changesets_from_manifest_ancestry(app); else if (idx(args, 0)() == "rosterify") build_roster_style_revs_from_manifest_style_revs(app); - else if (idx(args, 0)() == "regenerate_caches") + else if (idx(args, 0)() == "regenerate-caches") regenerate_caches(app); else throw usage(name); @@ -91,20 +91,20 @@ CMD(db, N_("database"), { if (idx(args, 0)() == "execute") app.db.debug(idx(args, 1)(), cout); - else if (idx(args, 0)() == "kill_rev_locally") + else if (idx(args, 0)() == "kill-rev-locally") kill_rev_locally(app,idx(args, 1)()); - else if (idx(args, 0)() == "clear_epoch") + else if (idx(args, 0)() == "clear-epoch") app.db.clear_epoch(branch_name(idx(args, 1)())); - else if (idx(args, 0)() == "kill_branch_certs_locally") + else if (idx(args, 0)() == "kill-branch-certs-locally") app.db.delete_branch_named(cert_value(idx(args, 1)())); - else if (idx(args, 0)() == "kill_tag_locally") + else if (idx(args, 0)() == "kill-tag-locally") app.db.delete_tag_named(cert_value(idx(args, 1)())); else throw usage(name); } else if (args.size() == 3) { - if (idx(args, 0)() == "set_epoch") + if (idx(args, 0)() == "set-epoch") { epoch_data ed(idx(args,2)()); N(ed.inner()().size() == constants::epochlen, ============================================================ --- commands.cc 6a8a053c6c687de7aeb91bb53f5beba7a7358c33 +++ commands.cc 3f88d20ac14273403ee6fe76031cf3bc23f6214a @@ -74,7 +74,10 @@ namespace commands { if (cmds == NULL) cmds = new map; - (*cmds)[n] = this; + + name = replace_underscores_with_dashes(name); + + (*cmds)[name] = this; } command::~command() {} std::string command::params() {return safe_gettext(params_.c_str());} ============================================================ --- simplestring_xform.cc 4d9df66d29c1e2b1ec4ef1717b271de71fd3d941 +++ simplestring_xform.cc f7e8187b4e03fb0a485ef30c3fe435811cdd18ae @@ -185,6 +185,19 @@ trim_ws(string const & s) return tmp; } +string +replace_underscores_with_dashes(string const & s) +{ + string tmp = s; + string::size_type loc = tmp.find("_"); + while (loc != string::npos) + { + tmp.replace(loc, 1, "-"); + loc = tmp.find("_"); + } + return tmp; +} + #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" #include @@ -230,6 +243,12 @@ UNIT_TEST(simplestring_xform, strip_ws) == "Ilikegoingforwalks"); } +UNIT_TEST(simplestring_xform, replace_underscores_with_dashes) +{ + BOOST_CHECK(replace_underscores_with_dashes("this_is_a_test") == "this-is-a-test"); + BOOST_CHECK(replace_underscores_with_dashes("nothing to do") == "nothing to do"); +} + #endif // BUILD_UNIT_TESTS // Local Variables: ============================================================ --- simplestring_xform.hh a3d2b3c5201493b1609578d624070636688c989e +++ simplestring_xform.hh 89cdfdba53791a234710fe3486538b6c32399177 @@ -34,6 +34,8 @@ std::string trim_ws(std::string const & // remove leading and trailing whitespace std::string trim_ws(std::string const & s); +std::string replace_underscores_with_dashes(std::string const & s); + // Local Variables: // mode: C++ // fill-column: 76