summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/other_tools/just_mr/cli.hpp3
-rw-r--r--src/other_tools/just_mr/exit_codes.hpp17
-rw-r--r--src/other_tools/just_mr/main.cpp12
3 files changed, 23 insertions, 9 deletions
diff --git a/src/other_tools/just_mr/cli.hpp b/src/other_tools/just_mr/cli.hpp
index c4773952..9543689e 100644
--- a/src/other_tools/just_mr/cli.hpp
+++ b/src/other_tools/just_mr/cli.hpp
@@ -109,7 +109,8 @@ enum class SubCommand {
kSetup,
kSetupEnv,
kJustDo,
- kJustSubCmd
+ kJustSubCmd,
+ kGcRepo
};
struct CommandLineArguments {
diff --git a/src/other_tools/just_mr/exit_codes.hpp b/src/other_tools/just_mr/exit_codes.hpp
index 8e5bf7cc..e4402538 100644
--- a/src/other_tools/just_mr/exit_codes.hpp
+++ b/src/other_tools/just_mr/exit_codes.hpp
@@ -17,14 +17,15 @@
enum JustMRExitCodes {
kExitSuccess = 0,
- kExitExecError = 64, // error in execvp
- kExitGenericFailure = 65, // none of the known errors
- kExitUnknownCommand = 66, // unknown subcommand error
- kExitClargsError = 67, // error in parsing clargs
- kExitConfigError = 68, // error in parsing config
- kExitFetchError = 69, // error in just-mr fetch
- kExitUpdateError = 70, // error in just-mr update
- kExitSetupError = 71 // error in just-mr setup(-env)
+ kExitExecError = 64, // error in execvp
+ kExitGenericFailure = 65, // none of the known errors
+ kExitUnknownCommand = 66, // unknown subcommand error
+ kExitClargsError = 67, // error in parsing clargs
+ kExitConfigError = 68, // error in parsing config
+ kExitFetchError = 69, // error in just-mr fetch
+ kExitUpdateError = 70, // error in just-mr update
+ kExitSetupError = 71, // error in just-mr setup(-env)
+ kExitBuiltinCommandFailure = 72 // error executing a built-in command
};
#endif // INCLUDED_SRC_OTHER_TOOLS_JUST_MR_EXIT_CODES_HPP
diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp
index 55447e54..f104e730 100644
--- a/src/other_tools/just_mr/main.cpp
+++ b/src/other_tools/just_mr/main.cpp
@@ -101,6 +101,8 @@ void SetupSetupCommandArguments(
"Advance Git commit IDs and print updated just-mr configuration.");
auto* cmd_do = app.add_subcommand(
"do", "Canonical way of specifying subcommands to be launched.");
+ auto* cmd_gc_repo = app.add_subcommand(
+ "gc-repo", "Perform garbage collection on the repository roots.");
cmd_do->set_help_flag(); // disable help flag
// define just subcommands
std::vector<CLI::App*> cmd_just_subcmds{};
@@ -158,6 +160,9 @@ void SetupSetupCommandArguments(
else if (*cmd_update) {
clargs.cmd = SubCommand::kUpdate;
}
+ else if (*cmd_gc_repo) {
+ clargs.cmd = SubCommand::kGcRepo;
+ }
else if (*cmd_do) {
clargs.cmd = SubCommand::kJustDo;
// get remaining args
@@ -316,6 +321,13 @@ auto main(int argc, char* argv[]) -> int {
return kExitGenericFailure;
}
+ if (arguments.cmd == SubCommand::kGcRepo) {
+ return RepositoryGarbageCollector::TriggerGarbageCollection(
+ *storage_config)
+ ? kExitSuccess
+ : kExitBuiltinCommandFailure;
+ }
+
auto const storage = Storage::Create(&*storage_config);
// check for conflicts in main repo name