aboutsummaryrefslogtreecommitdiff
path: root/src/zen/cmds/service_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zen/cmds/service_cmd.cpp')
-rw-r--r--src/zen/cmds/service_cmd.cpp54
1 files changed, 28 insertions, 26 deletions
diff --git a/src/zen/cmds/service_cmd.cpp b/src/zen/cmds/service_cmd.cpp
index db60d9b54..5011ac12f 100644
--- a/src/zen/cmds/service_cmd.cpp
+++ b/src/zen/cmds/service_cmd.cpp
@@ -98,7 +98,7 @@ namespace {
#else // ZEN_PLATFORM_WINDOWS
- bool IsElevated() { return true;/*geteuid() == 0;*/ }
+ bool IsElevated() { return true; /*geteuid() == 0;*/ }
#endif // ZEN_PLATFORM_WINDOWS
@@ -240,25 +240,32 @@ ServiceCommand::ServiceCommand()
ServiceCommand::~ServiceCommand() = default;
-std::string FmtServiceInfo(const ServiceInfo& Info, std::string_view Prefix)
+std::string
+FmtServiceInfo(const ServiceInfo& Info, std::string_view Prefix)
{
std::string Result = fmt::format(
"{}Status: {}\n"
"{}Executable: {}\n"
"{}CommandLineOptions: {}",
- Prefix, ToString(Info.Status),
- Prefix, Info.Spec.ExecutablePath,
- Prefix, Info.Spec.CommandLineOptions);
+ Prefix,
+ ToString(Info.Status),
+ Prefix,
+ Info.Spec.ExecutablePath,
+ Prefix,
+ Info.Spec.CommandLineOptions);
#if ZEN_PLATFORM_WINDOWS
- Result += fmt::format("\n"
+ Result += fmt::format(
+ "\n"
"{}Display Name: {}\n"
"{}Description: {}",
- Prefix, Info.Spec.DisplayName,
- Prefix, Info.Spec.Description);
-#endif // ZEN_PLATFORM_WINDOWS
+ Prefix,
+ Info.Spec.DisplayName,
+ Prefix,
+ Info.Spec.Description);
+#endif // ZEN_PLATFORM_WINDOWS
- return Result;
+ return Result;
}
int
@@ -302,10 +309,7 @@ ServiceCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
}
else
{
- ZEN_CONSOLE(
- "Service '{}':\n{}",
- m_ServiceName,
- FmtServiceInfo(Info, " "));
+ ZEN_CONSOLE("Service '{}':\n{}", m_ServiceName, FmtServiceInfo(Info, " "));
}
}
@@ -315,10 +319,7 @@ ServiceCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
std::error_code Ec = QueryInstalledService(m_ServiceName, Info);
if (!Ec && Info.Status != ServiceStatus::NotInstalled)
{
- ZEN_CONSOLE(
- "Service '{}' already installed:\n{}",
- m_ServiceName,
- FmtServiceInfo(Info, " "));
+ ZEN_CONSOLE("Service '{}' already installed:\n{}", m_ServiceName, FmtServiceInfo(Info, " "));
return 1;
}
@@ -334,14 +335,15 @@ ServiceCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
m_ServerExecutable = ExePath;
}
m_ServerExecutable = std::filesystem::absolute(m_ServerExecutable);
- Ec = InstallService(m_ServiceName,
- ServiceSpec{.ExecutablePath = m_ServerExecutable,
- .CommandLineOptions = GlobalOptions.PassthroughCommandLine
- #if ZEN_PLATFORM_WINDOWS
- ,.DisplayName = m_ServiceDisplayName
- ,.Description = m_ServiceDescription
- #endif // ZEN_PLATFORM_WINDOWS
- });
+ Ec = InstallService(
+ m_ServiceName,
+ ServiceSpec {
+ .ExecutablePath = m_ServerExecutable, .CommandLineOptions = GlobalOptions.PassthroughCommandLine
+#if ZEN_PLATFORM_WINDOWS
+ ,
+ .DisplayName = m_ServiceDisplayName, .Description = m_ServiceDescription
+#endif // ZEN_PLATFORM_WINDOWS
+ });
if (Ec)
{
ZEN_CONSOLE("Failed to install service '{}' using '{}' . Reason: '{}'", m_ServiceName, m_ServerExecutable, Ec.message());