core: add --version

This commit is contained in:
Vaxry 2024-09-29 18:24:57 +01:00
parent ed3f644af7
commit e22a8d437b
3 changed files with 11 additions and 3 deletions

View file

@ -10,6 +10,8 @@ project(
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS") set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
add_compile_definitions(HYPRPICKER_VERSION="${VERSION}")
message(STATUS "Configuring hyprpicker!") message(STATUS "Configuring hyprpicker!")
# Get git info hash and branch # Get git info hash and branch

View file

@ -14,7 +14,8 @@ static void help(void) {
<< " -z | --no-zoom | Disable the zoom lens\n" << " -z | --no-zoom | Disable the zoom lens\n"
<< " -q | --quiet | Disable most logs (leaves errors)\n" << " -q | --quiet | Disable most logs (leaves errors)\n"
<< " -v | --verbose | Enable more logs\n" << " -v | --verbose | Enable more logs\n"
<< " -t | --no-fractional | Disable fractional scaling support\n"; << " -t | --no-fractional | Disable fractional scaling support\n"
<< " -V | --version | Print version info\n";
} }
int main(int argc, char** argv, char** envp) { int main(int argc, char** argv, char** envp) {
@ -31,9 +32,10 @@ int main(int argc, char** argv, char** envp) {
{"no-fractional", no_argument, NULL, 't'}, {"no-fractional", no_argument, NULL, 't'},
{"quiet", no_argument, NULL, 'q'}, {"quiet", no_argument, NULL, 'q'},
{"verbose", no_argument, NULL, 'v'}, {"verbose", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0}}; {NULL, 0, NULL, 0}};
int c = getopt_long(argc, argv, ":f:hnarzqvt", long_options, &option_index); int c = getopt_long(argc, argv, ":f:hnarzqvtV", long_options, &option_index);
if (c == -1) if (c == -1)
break; break;
@ -62,6 +64,10 @@ int main(int argc, char** argv, char** envp) {
case 't': g_pHyprpicker->m_bNoFractional = true; break; case 't': g_pHyprpicker->m_bNoFractional = true; break;
case 'q': Debug::quiet = true; break; case 'q': Debug::quiet = true; break;
case 'v': Debug::verbose = true; break; case 'v': Debug::verbose = true; break;
case 'V': {
std::cout << "hyprpicker v" << HYPRPICKER_VERSION << "\n";
exit(0);
}
default: help(); exit(1); default: help(); exit(1);
} }