diff --git a/CatalystCX.hpp b/CatalystCX.hpp index 66a6acd..8f16d9f 100644 --- a/CatalystCX.hpp +++ b/CatalystCX.hpp @@ -11,6 +11,14 @@ */ #pragma once + +#if __cplusplus < 202002L + #error "CatalystCX requires C++20 or later (-std=c++20)" + #define CATALYST_VERSION_CHECK_FAILED +#endif + +#ifndef CATALYST_VERSION_CHECK_FAILED + #ifndef CATALYSTCX_HPP #define CATALYSTCX_HPP @@ -1245,4 +1253,6 @@ class SignalInfo { } }; -#endif \ No newline at end of file +#endif + +#endif diff --git a/Evaluate.cpp b/Evaluate.cpp index c7135e9..b87af4e 100644 --- a/Evaluate.cpp +++ b/Evaluate.cpp @@ -268,7 +268,7 @@ int main() { std::cout << "CatalystCX Test Suite" << std::endl; std::cout << "=====================" << std::endl; - + TestBasicExecution(runner); TestAsyncExecution(runner); TestTimeout(runner); diff --git a/README.md b/README.md index 580e685..730733c 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ CatalystCX provides a fluent API for building and executing commands with securi int main() { auto result = Command("echo").Arg("Hello, World!").Execute(); - std::cout << result.Stdout; // "Hello, World!\n" + std::cout << result.Vaule().Stdout; // "Hello, World!\n" return result.ExitCode; } ``` @@ -83,7 +83,7 @@ cp CatalystCX.hpp /your/project/include/ #include int main() { - CommandResult result = Command("ls").Arg("-l").Execute(); + CommandResult result = Command("ls").Arg("-l").Execute().Value(); std::cout << "Exit Code: " << result.ExitCode << std::endl; std::cout << "Stdout:\n" << result.Stdout << std::endl; @@ -103,7 +103,7 @@ int main() { return 1; } - const Child& child = spawn.Value(); + const auto& child = spawn.Value(); std::cout << "Process spawned with PID: " << child.GetPid() << std::endl; // ... do other work ... @@ -114,7 +114,7 @@ int main() { return 1; } - const CommandResult& result = wait.Value(); + const auto& result = wait.Value(); std::cout << "Sleep command finished. Exit: " << result.ExitCode << std::endl; } ``` @@ -126,7 +126,7 @@ auto result = Command("ping").Arg("8.8.8.8") .Timeout(std::chrono::seconds(2)) .Execute(); -if (result.TimedOut) { +if (result.Value().TimedOut) { std::cout << "Command timed out!" << std::endl; } ``` @@ -140,7 +140,7 @@ auto result = Command("printenv") .WorkingDirectory("/tmp") .Execute(); -std::cout << result.Stdout; // "Hello\n" +std::cout << result.Value().Stdout; // "Hello\n" ``` ### Signal Handling and Process Information @@ -269,7 +269,7 @@ while (retries-- > 0) { .Timeout(std::chrono::seconds(30)) .Execute(); - if (result.ExitCode == 0) break; + if (result.Vaule().ExitCode == 0) break; std::cerr << "Attempt failed, retries left: " << retries << std::endl; std::this_thread::sleep_for(std::chrono::seconds(1)); @@ -321,7 +321,7 @@ if (!res.IsSuccessful()) { ErrorInfo contains: - Code (ErrorCode): e.g., ExecutableNotFound, SpawnFailed, ExecutionTimeout - Category (ErrorCategory): Validation, System, Process, Timeout, Permission, Resource, Platform -- Message, Details, Suggestion and SystemErrorCode +- Message, Details, Suggestion, and SystemErrorCode ## API Reference (Quick)