Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CatalystCX.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -1245,4 +1253,6 @@ class SignalInfo {
}
};

#endif
#endif

#endif
2 changes: 1 addition & 1 deletion Evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ int main() {

std::cout << "CatalystCX Test Suite" << std::endl;
std::cout << "=====================" << std::endl;

TestBasicExecution(runner);
TestAsyncExecution(runner);
TestTimeout(runner);
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
```
Expand Down Expand Up @@ -83,7 +83,7 @@ cp CatalystCX.hpp /your/project/include/
#include <iostream>

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;
Expand All @@ -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 ...
Expand All @@ -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;
}
```
Expand All @@ -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;
}
```
Expand All @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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)

Expand Down