# # # add_dir "tests/test_the_version_command" # # add_file "tests/test_the_version_command/__driver__.lua" # content [6095698f688c9e07c2dfd67bd479300e730735ec] # # patch "cmd_db.cc" # from [92cbc7d5943e8b896749ad4f86a05a7437bed50e] # to [289e16716dee7ba5e02eb87ba6608cc5fa379e3a] # # patch "monotone.cc" # from [d9da9bb00dbed1bba52892eac09aa974e8b2c2b0] # to [dda8e6aa3418fe634c5324f4b5d026463d8c019c] # # patch "mt_version.cc" # from [a146b93aa0550b024bf41bbb4f0fcd1b8378a57d] # to [dbf4efd1b6984b533ea72e4a247adb1f0862bb3f] # # patch "options_list.hh" # from [c6f757559003724a53598a123eaad448274ecaec] # to [b3ccd0af968b5f1f375de18267d86c10b10fd423] # # patch "ui.cc" # from [5a81f282c648b1a3ed51475e214ec5475652b07e] # to [6a72078cb0090454028f61c65ff5698a1a877037] # ============================================================ --- tests/test_the_version_command/__driver__.lua 6095698f688c9e07c2dfd67bd479300e730735ec +++ tests/test_the_version_command/__driver__.lua 6095698f688c9e07c2dfd67bd479300e730735ec @@ -0,0 +1,24 @@ + +mtn_setup() + +-- The 'version' command behaves exactly as the '--version' option. +check(mtn("version"), 0, true, 0) +rename("stdout", "out") +check(mtn("--version"), 0, true, 0) +check(samefile("stdout", "out")) + +-- The 'version' command prints no detailed information. +check(mtn("version"), 0, true, 0) +output = readfile("stdout") +check(string.find(output, "Running on") == nil) + +-- The 'version' command allows a '--full' option. +check(mtn("version", "--full"), 0, true, 0) +output = readfile("stdout") +check(string.find(output, "Running on") ~= nil) + +-- The '--version' option does not allow a '--full' option (because the +-- latter is not global). +check(mtn("--version", "--full"), 0, true, 0) +output = readfile("stdout") +check(string.find(output, "Running on") == nil) ============================================================ --- cmd_db.cc 92cbc7d5943e8b896749ad4f86a05a7437bed50e +++ cmd_db.cc 289e16716dee7ba5e02eb87ba6608cc5fa379e3a @@ -49,7 +49,7 @@ kill_rev_locally(app_state& app, string app.db.delete_existing_rev_and_certs(ident); } -CMD(init, "init", "", CMD_REF(db), "", +CMD(db_init, "init", "", CMD_REF(db), "", N_("Initializes a database"), N_("Creates a new database file and initializes it."), options::opts::none) @@ -60,7 +60,7 @@ CMD(init, "init", "", CMD_REF(db), "", app.db.initialize(); } -CMD(info, "info", "", CMD_REF(db), "", +CMD(db_info, "info", "", CMD_REF(db), "", N_("Shows information about the database"), N_(""), options::opts::none) @@ -71,7 +71,7 @@ CMD(info, "info", "", CMD_REF(db), "", app.db.info(cout); } -CMD(version, "version", "", CMD_REF(db), "", +CMD(db_version, "version", "", CMD_REF(db), "", N_("Shows the database's version"), N_(""), options::opts::none) @@ -82,7 +82,7 @@ CMD(version, "version", "", CMD_REF(db), app.db.version(cout); } -CMD(dump, "dump", "", CMD_REF(db), "", +CMD(db_dump, "dump", "", CMD_REF(db), "", N_("Dumps the contents of the database"), N_("Generates a list of SQL instructions that represent the whole " "contents of the database. The resulting output is useful to later " @@ -95,7 +95,7 @@ CMD(dump, "dump", "", CMD_REF(db), "", app.db.dump(cout); } -CMD(load, "load", "", CMD_REF(db), "", +CMD(db_load, "load", "", CMD_REF(db), "", N_("Loads the contents of the database"), N_("Reads a list of SQL instructions that regenerate the contents of " "the database. This is supposed to be used in conjunction with the " @@ -108,7 +108,7 @@ CMD(load, "load", "", CMD_REF(db), "", app.db.load(cin); } -CMD(migrate, "migrate", "", CMD_REF(db), "", +CMD(db_migrate, "migrate", "", CMD_REF(db), "", N_("Migrates the database to a newer schema"), N_("Updates the database's internal schema to the most recent one. " "Needed to automatically resolve incompatibilities that may be " @@ -121,7 +121,7 @@ CMD(migrate, "migrate", "", CMD_REF(db), app.db.migrate(); } -CMD(execute, "execute", "", CMD_REF(db), "", +CMD(db_execute, "execute", "", CMD_REF(db), "", N_("Executes an SQL command on the database"), N_("Directly executes the given SQL command on the database"), options::opts::none) @@ -132,7 +132,7 @@ CMD(execute, "execute", "", CMD_REF(db), app.db.debug(idx(args, 0)(), cout); } -CMD(kill_rev_locally, "kill_rev_locally", "", CMD_REF(db), "ID", +CMD(db_kill_rev_locally, "kill_rev_locally", "", CMD_REF(db), "ID", N_("Kills a revision from the local database"), N_(""), options::opts::none) @@ -143,7 +143,7 @@ CMD(kill_rev_locally, "kill_rev_locally" kill_rev_locally(app,idx(args, 0)()); } -CMD(kill_branch_certs_locally, "kill_branch_certs_locally", "", CMD_REF(db), +CMD(db_kill_branch_certs_locally, "kill_branch_certs_locally", "", CMD_REF(db), "BRANCH", N_("Kills branch certificates from the local database"), N_(""), @@ -155,7 +155,7 @@ CMD(kill_branch_certs_locally, "kill_bra app.db.delete_branch_named(cert_value(idx(args, 0)())); } -CMD(kill_tag_locally, "kill_tag_locally", "", CMD_REF(db), "TAG", +CMD(db_kill_tag_locally, "kill_tag_locally", "", CMD_REF(db), "TAG", N_("Kills a tag from the local database"), N_(""), options::opts::none) @@ -166,7 +166,7 @@ CMD(kill_tag_locally, "kill_tag_locally" app.db.delete_tag_named(cert_value(idx(args, 0)())); } -CMD(check, "check", "", CMD_REF(db), "", +CMD(db_check, "check", "", CMD_REF(db), "", N_("Does some sanity checks on the database"), N_("Ensures that the database is consistent by issuing multiple " "checks."), @@ -178,7 +178,7 @@ CMD(check, "check", "", CMD_REF(db), "", check_db(app); } -CMD(changesetify, "changesetify", "", CMD_REF(db), "", +CMD(db_changesetify, "changesetify", "", CMD_REF(db), "", N_("Converts the database to the changeset format"), N_(""), options::opts::none) @@ -189,7 +189,7 @@ CMD(changesetify, "changesetify", "", CM build_changesets_from_manifest_ancestry(app); } -CMD(rosterify, "rosterify", "", CMD_REF(db), "", +CMD(db_rosterify, "rosterify", "", CMD_REF(db), "", N_("Converst the database to the rosters format"), N_(""), options::opts::drop_attr) @@ -200,7 +200,7 @@ CMD(rosterify, "rosterify", "", CMD_REF( build_roster_style_revs_from_manifest_style_revs(app); } -CMD(regenerate_caches, "regenerate_caches", "", CMD_REF(db), "", +CMD(db_regenerate_caches, "regenerate_caches", "", CMD_REF(db), "", N_("Regenerates the caches stored in the database"), N_(""), options::opts::none) @@ -222,7 +222,7 @@ CMD_HIDDEN(clear_epoch, "clear_epoch", " app.db.clear_epoch(branch_name(idx(args, 0)())); } -CMD(set_epoch, "set_epoch", "", CMD_REF(db), "BRANCH EPOCH", +CMD(db_set_epoch, "set_epoch", "", CMD_REF(db), "BRANCH EPOCH", N_("Sets the database's epoch"), N_(""), options::opts::none) ============================================================ --- monotone.cc d9da9bb00dbed1bba52892eac09aa974e8b2c2b0 +++ monotone.cc dda8e6aa3418fe634c5324f4b5d026463d8c019c @@ -221,12 +221,6 @@ cpp_main(int argc, char ** argv) return 0; } - if (app.opts.full_version_given) - { - print_full_version(); - return 0; - } - if (app.opts.dbname_given) { if (!app.opts.dbname.empty()) ============================================================ --- mt_version.cc a146b93aa0550b024bf41bbb4f0fcd1b8378a57d +++ mt_version.cc dbf4efd1b6984b533ea72e4a247adb1f0862bb3f @@ -19,6 +19,8 @@ #include #include +#include "app_state.hh" +#include "cmd.hh" #include "platform.hh" #include "mt_version.hh" #include "package_revision.h" @@ -29,6 +31,22 @@ using std::string; using std::ostringstream; using std::string; +CMD(version, "version", "", CMD_REF(informative), "", + N_("Shows the program version"), + N_(""), + options::opts::full) +{ + N(args.size() == 0, + F("no arguments allowed")); + + string version; + if (app.opts.full) + get_full_version(version); + else + get_version(version); + cout << version << '\n'; +} + void get_version(string & out) { ============================================================ --- options_list.hh c6f757559003724a53598a123eaad448274ecaec +++ options_list.hh b3ccd0af968b5f1f375de18267d86c10b10fd423 @@ -258,11 +258,11 @@ GOPT(ssh_sign, "ssh-sign", std::string, } #endif -GOPT(full_version, "full-version", bool, false, - gettext_noop("print detailed version number, then exit")) +OPT(full, "full", bool, false, + gettext_noop("print detailed version number")) #ifdef option_bodies { - full_version = true; + full = true; } #endif ============================================================ --- ui.cc 5a81f282c648b1a3ed51475e214ec5475652b07e +++ ui.cc 6a72078cb0090454028f61c65ff5698a1a877037 @@ -476,7 +476,7 @@ user_interface::fatal(string const & fat { inform(F("fatal: %s\n" "this is almost certainly a bug in monotone.\n" - "please send this error message, the output of '%s --full-version',\n" + "please send this error message, the output of '%s version --full',\n" "and a description of what you were doing to %s.") % fatal % prog_name % PACKAGE_BUGREPORT); global_sanity.dump_buffer();