aboutsummaryrefslogtreecommitdiff
path: root/src/zen/cmds/service_cmd.h
blob: ee98620d1d25d42388b1259b913b44342c329914 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "../zen.h"

#include <filesystem>

namespace zen {

class ServiceCommand : public ZenCmdBase
{
public:
	static constexpr char Name[]		= "service";
	static constexpr char Description[] = "Manage zenserver as a service - status, install, uninstall, start and stop";

	ServiceCommand();
	~ServiceCommand();

	virtual void			  Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) override;
	virtual cxxopts::Options& Options() override { return m_Options; }

private:
	cxxopts::Options m_Options{Name, Description};

	std::string m_Verb;	 // create, info, remove

	std::string m_ServiceName = "ZenServer";
	std::string m_UserName;

	bool m_AllowElevation = false;

	cxxopts::Options m_StatusOptions{"status", "Show information about an installed zenserver service"};

	cxxopts::Options m_InstallOptions{
		"install",
		"Install zenserver as a service. Arguments following \" -- \" will be added as parameters to the installed service."};
	std::filesystem::path m_ServerExecutable;
	std::filesystem::path m_InstallPath;
	bool				  m_FullInstall = false;
#if ZEN_PLATFORM_WINDOWS
	std::string m_ServiceDisplayName = "Unreal Zen Storage Service";
	std::string m_ServiceDescription;
#endif	// ZEN_PLATFORM_WINDOWS

	cxxopts::Options m_UninstallOptions{"uninstall", "Uninstall zenserver as a service"};

	cxxopts::Options m_StartOptions{"start", "Start an installed zenserver service"};

	cxxopts::Options m_StopOptions{"stop", "Start an installed zenserver service"};

	cxxopts::Options* m_SubCommands[5] = {&m_StatusOptions, &m_InstallOptions, &m_UninstallOptions, &m_StartOptions, &m_StopOptions};
};

}  // namespace zen