diff --git a/cpp/Platform.Interfaces.Tests/Platform.Interfaces.Tests.cpp b/cpp/Platform.Interfaces.Tests/Platform.Interfaces.Tests.cpp index c59ac91..e94e7fd 100644 --- a/cpp/Platform.Interfaces.Tests/Platform.Interfaces.Tests.cpp +++ b/cpp/Platform.Interfaces.Tests/Platform.Interfaces.Tests.cpp @@ -140,4 +140,17 @@ namespace Platform::Interfaces::Tests { ASSERT_TRUE((CSetter)); } } + + TEST(CompileTests, Cli) { + struct EmptyCli : public ICli { + int Run(const std::vector& args) override { return 0; } + }; + static_assert(CCli); + + { + CCli auto cli = EmptyCli{}; + + ASSERT_TRUE((CCli)); + } + } } // namespace Platform::Interfaces::Tests diff --git a/cpp/Platform.Interfaces/CCli.h b/cpp/Platform.Interfaces/CCli.h new file mode 100644 index 0000000..2843a8c --- /dev/null +++ b/cpp/Platform.Interfaces/CCli.h @@ -0,0 +1,12 @@ +#pragma once + +#include +#include +#include + +namespace Platform::Interfaces { + template + concept CCli = requires(TSelf self, const std::vector& args) { + { self.Run(args) } -> std::same_as; + }; +} // namespace Platform::Interfaces \ No newline at end of file diff --git a/cpp/Platform.Interfaces/ICli.h b/cpp/Platform.Interfaces/ICli.h new file mode 100644 index 0000000..86edc18 --- /dev/null +++ b/cpp/Platform.Interfaces/ICli.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include + +namespace Platform::Interfaces { + /// + /// Defines command line interfaces for command that interacts with an operating system. + /// Определяет интерфейс командной строки, для команды взаимодействующей с операционной системой. + /// + struct ICli { + /// + /// Runs a command. + /// Запускает команду. + /// + /// + /// Arguments for a command. + /// Аргументы для команды. + /// + /// + /// Returns command's exit code. + /// Возвращает код выхода команды. + /// + virtual int Run(const std::vector& args) = 0; + + virtual ~ICli() = default; + }; +} // namespace Platform::Interfaces \ No newline at end of file diff --git a/cpp/Platform.Interfaces/Platform.Interfaces.h b/cpp/Platform.Interfaces/Platform.Interfaces.h index e6cbd2f..b50bdd3 100644 --- a/cpp/Platform.Interfaces/Platform.Interfaces.h +++ b/cpp/Platform.Interfaces/Platform.Interfaces.h @@ -14,6 +14,7 @@ #include "CProvider.h" #include "CSetter.h" #include "CProperty.h" +#include "CCli.h" #include "ICounter[TResult, TArgument].h" #include "ICounter[TResult].h" @@ -25,6 +26,7 @@ #include "IProvider[TProvided].h" #include "ISetter[TValue, TArgument].h" #include "ISetter[TValue].h" +#include "ICli.h" #include "Polymorph.h"