From 541edbb79bf69b98ebeb7bf7b2305eaa0252fde2 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Mon, 28 Feb 2022 13:04:43 +0100 Subject: CLI: Add option to set action timeout --- src/buildtool/common/cli.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/buildtool/common/cli.hpp') diff --git a/src/buildtool/common/cli.hpp b/src/buildtool/common/cli.hpp index 97efb9d3..7e93b9ec 100644 --- a/src/buildtool/common/cli.hpp +++ b/src/buildtool/common/cli.hpp @@ -1,6 +1,7 @@ #ifndef INCLUDED_SRC_BUILDTOOL_COMMON_CLI_HPP #define INCLUDED_SRC_BUILDTOOL_COMMON_CLI_HPP +#include #include #include #include @@ -14,6 +15,7 @@ #include "src/buildtool/logging/log_level.hpp" constexpr auto kDefaultLogLevel = LogLevel::Info; +constexpr auto kDefaultTimeout = std::chrono::milliseconds{300000}; /// \brief Arguments common to all commands. struct CommonArguments { @@ -59,6 +61,7 @@ struct EndpointArguments { struct BuildArguments { std::optional> local_launcher{std::nullopt}; std::map platform_properties; + std::chrono::milliseconds timeout{kDefaultTimeout}; std::size_t build_jobs{}; std::optional dump_artifacts{std::nullopt}; std::optional print_to_stdout{std::nullopt}; @@ -269,6 +272,14 @@ static inline auto SetupBuildArguments( ->allow_extra_args(false) ->expected(1, 1); + app->add_option_function( + "--action_timeout", + [clargs](auto const& seconds) { + clargs->timeout = seconds * std::chrono::seconds{1}; + }, + "Action timeout in seconds. (Default: 300).") + ->type_name("NUM"); + app->add_option( "-J,--build_jobs", clargs->build_jobs, -- cgit v1.2.3