core: add --version and improve --help

This commit is contained in:
Vaxry 2024-09-21 16:45:23 +01:00
parent a8ebdcb011
commit 15932f0f9e
2 changed files with 11 additions and 5 deletions

View file

@ -21,6 +21,8 @@ else()
message(STATUS "Configuring XDPH in Release with CMake") message(STATUS "Configuring XDPH in Release with CMake")
endif() endif()
add_compile_definitions(XDPH_VERSION="${VER}")
include_directories(. "protocols/") include_directories(. "protocols/")
# configure # configure

View file

@ -4,11 +4,12 @@
#include "core/PortalManager.hpp" #include "core/PortalManager.hpp"
void printHelp() { void printHelp() {
std::cout << R"#(| xdg-desktop-portal-hyprland std::cout << R"#(┃ xdg-desktop-portal-hyprland
| --------------------------------------
| -v (--verbose) > enable trace logging -v (--verbose) enable trace logging
| -q (--quiet) > disable logging -q (--quiet) disable logging
| -h (--help) > print this menu -h (--help) print this menu
-V (--version) print xdph's version
)#"; )#";
} }
@ -27,6 +28,9 @@ int main(int argc, char** argv, char** envp) {
else if (arg == "--help" || arg == "-h") { else if (arg == "--help" || arg == "-h") {
printHelp(); printHelp();
return 0; return 0;
} else if (arg == "--version" || arg == "-V") {
std::cout << "xdg-desktop-portal-hyprland v" << XDPH_VERSION << "\n";
return 0;
} else { } else {
printHelp(); printHelp();
return 1; return 1;