diff options
| author | Liam Mitchell <[email protected]> | 2025-03-26 15:23:15 -0700 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-03-26 15:23:15 -0700 |
| commit | 270e8479281ae580fa6456dc220e12f3e103f156 (patch) | |
| tree | 67ef3e0aff66e4ebbee4d0acf1de399e1fbc511d /src | |
| parent | Merge pull request #323 from ue-foundation/lm/zen-service-restart-options (diff) | |
| parent | Update return codes for service commands to provide more information to the c... (diff) | |
| download | zen-270e8479281ae580fa6456dc220e12f3e103f156.tar.xz zen-270e8479281ae580fa6456dc220e12f3e103f156.zip | |
Merge pull request #322 from ue-foundation/lm/zen-service-return-codes
Update return codes for service commands to provide more information to the caller
Diffstat (limited to 'src')
| -rw-r--r-- | src/zen/cmds/service_cmd.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/zen/cmds/service_cmd.cpp b/src/zen/cmds/service_cmd.cpp index 386046e66..fd4d3895e 100644 --- a/src/zen/cmds/service_cmd.cpp +++ b/src/zen/cmds/service_cmd.cpp @@ -92,6 +92,7 @@ namespace { else { ZEN_CONSOLE("Failed to run elevated, operation did not complete."); + ReturnCode = DWORD(-1); } return (int)ReturnCode; } @@ -272,6 +273,14 @@ FmtServiceInfo(const ServiceInfo& Info, std::string_view Prefix) return Result; } +enum class ServiceStatusReturnCode +{ + Running = 0, // successful return indicates proper installation and everything running smoothly + NotInstalled, + NotRunning, + UnknownError +}; + int ServiceCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) { @@ -304,12 +313,17 @@ ServiceCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) if (Ec) { ZEN_CONSOLE("Can't get information about service '{}'. Reason: '{}'", m_ServiceName, Ec.message()); - return 1; + return gsl::narrow<int>(ServiceStatusReturnCode::UnknownError); } if (Info.Status == ServiceStatus::NotInstalled) { ZEN_CONSOLE("Service '{}' is not installed", m_ServiceName); - return 0; + return gsl::narrow<int>(ServiceStatusReturnCode::NotInstalled); + } + else if (Info.Status != ServiceStatus::Running) + { + ZEN_CONSOLE("Service '{}' is not running", m_ServiceName); + return gsl::narrow<int>(ServiceStatusReturnCode::NotRunning); } else { |