From 64f5d884e4592b2e6f872db3d8a020ab2d6f8416 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Mon, 18 Mar 2024 12:58:05 +0100 Subject: Add new subcommand add-to-cas --- src/buildtool/common/cli.hpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/buildtool/common/cli.hpp') diff --git a/src/buildtool/common/cli.hpp b/src/buildtool/common/cli.hpp index 7b4f3987..6b6be63a 100644 --- a/src/buildtool/common/cli.hpp +++ b/src/buildtool/common/cli.hpp @@ -607,6 +607,34 @@ static inline auto SetupFetchArguments( "--remember", clargs->remember, "Copy object to local CAS first"); } +static inline auto SetupToAddArguments( + gsl::not_null const& app, + gsl::not_null const& clargs) { + app->add_option_function( + "location", + [clargs](auto const& path_raw) { + std::filesystem::path in = ToNormalPath(path_raw); + if (not in.is_absolute()) { + try { + in = std::filesystem::absolute(in); + } catch (std::exception const& e) { + Logger::Log(LogLevel::Error, + "Failed to convert input path {} ({})", + path_raw, + e.what()); + throw e; + } + } + clargs->location = in; + }, + "The path on the local file system to be added to CAS") + ->required(); + app->add_flag("--follow-symlinks", + clargs->follow_symlinks, + "Resolve the positional argument to not be a symbolic link " + "before adding it to CAS."); +} + static inline auto SetupGraphArguments( gsl::not_null const& app, gsl::not_null const& clargs) { -- cgit v1.2.3