aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLiam Mitchell <[email protected]>2025-03-25 17:33:05 -0700
committerLiam Mitchell <[email protected]>2025-03-25 17:43:32 -0700
commitffe14640c54887d5daf4c1e76547c171e7b644e8 (patch)
tree465c8567f59eedc9288904b9b34b991104a39678 /src
parentMerge remote-tracking branch 'origin/main' into de/zen-service-command (diff)
downloadzen-ffe14640c54887d5daf4c1e76547c171e7b644e8.tar.xz
zen-ffe14640c54887d5daf4c1e76547c171e7b644e8.zip
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.cpp18
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
{