refactor: app Replace options defines as constexpr use more sane names

This commit is contained in:
sithlord48 2025-07-03 11:49:57 -04:00 committed by Nick Bolton
parent 66ddaca410
commit 1a9f8d5cdc
3 changed files with 41 additions and 47 deletions

View file

@ -130,59 +130,53 @@ private:
#else #else
#define DAEMON_RUNNING(running_) #define DAEMON_RUNNING(running_)
#endif #endif
constexpr static auto s_helpGeneralArgs = //
" -d, --debug <level> filter out log messages with priority below level.\n"
" level may be: FATAL, ERROR, WARNING, NOTE, INFO,\n"
" DEBUG, DEBUG1, DEBUG2.\n"
" -n, --name <screen-name> use screen-name instead the hostname to identify\n"
" this screen in the configuration.\n"
" -1, --no-restart do not try to restart on failure.\n"
"* --restart restart the server automatically if it fails.\n"
" -l --log <file> write log messages to file.\n"
" --enable-crypto enable TLS encryption.\n"
" --tls-cert specify the path to the TLS certificate file.\n";
#define HELP_COMMON_INFO_1 \ constexpr static auto s_helpVersionArgs = //
" -d, --debug <level> filter out log messages with priority below " \ " -h, --help display this help and exit.\n"
"level.\n" \ " --version display version information and exit.\n";
" level may be: FATAL, ERROR, WARNING, NOTE, " \
"INFO,\n" \
" DEBUG, DEBUG1, DEBUG2.\n" \
" -n, --name <screen-name> use screen-name instead the hostname to " \
"identify\n" \
" this screen in the configuration.\n" \
" -1, --no-restart do not try to restart on failure.\n" \
"* --restart restart the server automatically if it fails.\n" \
" -l --log <file> write log messages to file.\n" \
" --enable-crypto enable TLS encryption.\n" \
" --tls-cert specify the path to the TLS certificate file.\n"
#define HELP_COMMON_INFO_2 \ constexpr static auto s_helpCommonArgs = //
" -h, --help display this help and exit.\n" \ " [--name <screen-name>]"
" --version display version information and exit.\n" " [--restart|--no-restart]"
" [--debug <level>]";
#define HELP_COMMON_ARGS \
" [--name <screen-name>]" \
" [--restart|--no-restart]" \
" [--debug <level>]"
// system args (windows/unix) // system args (windows/unix)
#if SYSAPI_UNIX #if SYSAPI_UNIX
// unix daemon mode args // unix daemon mode args
#define HELP_SYS_ARGS " [--daemon|--no-daemon]" constexpr static auto s_helpSysArgs = " [--daemon|--no-daemon]";
#define HELP_SYS_INFO \ constexpr static auto s_helpSysInfo = //
" -f, --no-daemon run in the foreground.\n" \ " -f, --no-daemon run in the foreground.\n"
"* --daemon run as a daemon.\n" "* --daemon run as a daemon.\n";
#elif SYSAPI_WIN32 #elif SYSAPI_WIN32
// windows args // windows args
#define HELP_SYS_ARGS " [--service <action>] [--relaunch]" constexpr static auto s_helpSysArgs = " [--service <action>] [--relaunch]";
#define HELP_SYS_INFO \ constexpr static auto s_helpSysInfo = //
" --service <action> manage the windows service, valid options " \ " --service <action> manage the windows service, valid options are:\n"
"are:\n" \ " install/uninstall/start/stop\n"
" install/uninstall/start/stop\n" \ " --relaunch persistently relaunches process in current user \n"
" --relaunch persistently relaunches process in current " \ " session (useful for vista and upward).\n";
"user \n" \
" session (useful for vista and upward).\n"
#endif #endif
#if !defined(WINAPI_LIBEI) && WINAPI_XWINDOWS #if !defined(WINAPI_LIBEI) && WINAPI_XWINDOWS
const auto kHelpNoWayland = "\n" constexpr static auto s_helpNoWayland = //
"Your Linux distribution does not support Wayland EI (emulated input)\n" "\nYour Linux distribution does not support Wayland EI (emulated input)\n"
"which is required for Wayland support. Please use a Linux distribution\n" "which is required for Wayland support. Please use a Linux distribution\n"
"that supports Wayland EI.\n"; "that supports Wayland EI.\n";
#else #else
const auto kHelpNoWayland = ""; constexpr static auto s_helpNoWayland = "";
#endif #endif

View file

@ -106,12 +106,12 @@ void ClientApp::help()
#ifdef WINAPI_XWINDOWS #ifdef WINAPI_XWINDOWS
<< " [--display <display>]" << " [--display <display>]"
#endif #endif
<< HELP_SYS_ARGS << HELP_COMMON_ARGS << " <server-address>" << s_helpSysArgs << s_helpCommonArgs << " <server-address>"
<< "\n\n" << "\n\n"
<< "Connect to a " << kAppName << " mouse/keyboard sharing server.\n" << "Connect to a " << kAppName << " mouse/keyboard sharing server.\n"
<< "\n" << "\n"
<< " -a, --address <address> local network interface address.\n" << " -a, --address <address> local network interface address.\n"
<< HELP_COMMON_INFO_1 << HELP_SYS_INFO << " --yscroll <delta> defines the vertical scrolling delta,\n" << s_helpGeneralArgs << s_helpSysInfo << " --yscroll <delta> defines the vertical scrolling delta,\n"
<< " which is 120 by default.\n" << " which is 120 by default.\n"
<< " --sync-language enable language synchronization.\n" << " --sync-language enable language synchronization.\n"
<< " --invert-scroll invert scroll direction on this\n" << " --invert-scroll invert scroll direction on this\n"
@ -120,10 +120,10 @@ void ClientApp::help()
<< " --display <display> when in X mode, connect to the X server\n" << " --display <display> when in X mode, connect to the X server\n"
<< " at <display>.\n" << " at <display>.\n"
#endif #endif
<< HELP_COMMON_INFO_2 << "\n" << s_helpVersionArgs << "\n"
<< "* marks defaults.\n" << "* marks defaults.\n"
<< kHelpNoWayland << s_helpNoWayland
<< "\n" << "\n"
<< "The server address is of the form: [<hostname>][:<port>].\n" << "The server address is of the form: [<hostname>][:<port>].\n"

View file

@ -109,16 +109,16 @@ void ServerApp::help()
<< " [--display <display>]" << " [--display <display>]"
#endif #endif
<< HELP_SYS_ARGS HELP_COMMON_ARGS "\n" << s_helpSysArgs << s_helpCommonArgs << "\n"
<< "\n" << "\n"
<< "Start the " << kAppName << " mouse/keyboard sharing server.\n" << "Start the " << kAppName << " mouse/keyboard sharing server.\n"
<< "\n" << "\n"
<< " -a, --address <address> listen for clients on the given address.\n" << " -a, --address <address> listen for clients on the given address.\n"
<< " -c, --config <pathname> path of the configuration file\n" << " -c, --config <pathname> path of the configuration file\n"
<< HELP_COMMON_INFO_1 << s_helpGeneralArgs
<< " --disable-client-cert-check disable client SSL certificate \n" << " --disable-client-cert-check disable client SSL certificate \n"
" checking (deprecated)\n" " checking (deprecated)\n"
<< HELP_SYS_INFO HELP_COMMON_INFO_2 << "\n" << s_helpSysInfo << s_helpVersionArgs << "\n"
#if WINAPI_XWINDOWS #if WINAPI_XWINDOWS
<< " --display <display> when in X mode, connect to the X server\n" << " --display <display> when in X mode, connect to the X server\n"
@ -127,7 +127,7 @@ void ServerApp::help()
<< "* marks defaults.\n" << "* marks defaults.\n"
<< kHelpNoWayland << s_helpNoWayland
<< "\n" << "\n"
<< "The argument for --address is of the form: [<hostname>][:<port>]. " << "The argument for --address is of the form: [<hostname>][:<port>]. "