diff options
-rw-r--r-- | share/man/just-mr.1.org | 7 | ||||
-rw-r--r-- | src/other_tools/just_mr/TARGETS | 1 | ||||
-rw-r--r-- | src/other_tools/just_mr/main.cpp | 14 |
3 files changed, 21 insertions, 1 deletions
diff --git a/share/man/just-mr.1.org b/share/man/just-mr.1.org index 136796f4..b7a128f1 100644 --- a/share/man/just-mr.1.org +++ b/share/man/just-mr.1.org @@ -92,6 +92,13 @@ See *just-mr-repository-config(5)* for more details on the input format. * SUBCOMMANDS +** mrversion + +Print on stdout a JSON object providing version information for +this tool itself; the ~version~ subcommand calls the ~version~ +subcommand of just. The version information for just-mr is in the +same format that also ~just~ uses. + ** setup|setup-env These subcommands fetch all required repositories and generate an appropriate diff --git a/src/other_tools/just_mr/TARGETS b/src/other_tools/just_mr/TARGETS index e534d986..478a65b0 100644 --- a/src/other_tools/just_mr/TARGETS +++ b/src/other_tools/just_mr/TARGETS @@ -6,6 +6,7 @@ , "private-deps": [ ["src/buildtool/build_engine/expression", "expression"] , ["src/buildtool/logging", "logging"] + , ["src/buildtool/main", "version"] , "cli" , "exit_codes" , ["src/other_tools/ops_maps", "repo_fetch_map"] diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp index 8448b44b..3888dddb 100644 --- a/src/other_tools/just_mr/main.cpp +++ b/src/other_tools/just_mr/main.cpp @@ -19,6 +19,7 @@ #include "src/buildtool/logging/log_config.hpp" #include "src/buildtool/logging/log_sink_cmdline.hpp" #include "src/buildtool/logging/log_sink_file.hpp" +#include "src/buildtool/main/version.hpp" #include "src/other_tools/just_mr/cli.hpp" #include "src/other_tools/just_mr/exit_codes.hpp" #include "src/other_tools/ops_maps/git_update_map.hpp" @@ -29,6 +30,7 @@ namespace { enum class SubCommand { kUnknown, + kMRVersion, kFetch, kUpdate, kSetup, @@ -87,6 +89,8 @@ void SetupSetupCommandArguments( -> CommandLineArguments { CLI::App app("just-mr"); app.option_defaults()->take_last(); + auto* cmd_mrversion = app.add_subcommand( + "mrversion", "Print version information in JSON format of this tool."); auto* cmd_setup = app.add_subcommand("setup", "Setup and generate just configuration"); auto* cmd_setup_env = app.add_subcommand( @@ -136,7 +140,10 @@ void SetupSetupCommandArguments( std::exit(kExitClargsError); } - if (*cmd_setup) { + if (*cmd_mrversion) { + clargs.cmd = SubCommand::kMRVersion; + } + else if (*cmd_setup) { clargs.cmd = SubCommand::kSetup; } else if (*cmd_setup_env) { @@ -1122,6 +1129,11 @@ auto main(int argc, char* argv[]) -> int { // get the user-defined arguments auto arguments = ParseCommandLineArguments(argc, argv); + if (arguments.cmd == SubCommand::kMRVersion) { + std::cout << version() << std::endl; + return kExitSuccess; + } + SetupLogging(arguments.log); auto config_file = ReadJustMRRC(&arguments); if (arguments.common.repository_config) { |