diff --git a/makefile b/makefile index a6e2599..40ac575 100644 --- a/makefile +++ b/makefile @@ -3,6 +3,7 @@ CC=gcc #CC=gcc -O3 #CC=tcc FLAGS=-std=c99 -pedantic -Wall -Werror=vla -Werror -g +FLAGS+=-DGIT_VERSION_STRING=\"$(shell git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g')\" OS:=$(shell uname -s) ifeq ($(OS),Linux) diff --git a/src/main.c b/src/main.c index 7880597..0b72e3d 100644 --- a/src/main.c +++ b/src/main.c @@ -8,11 +8,33 @@ #include "util.h" #include #include +#include enum active_input {INPUT_DESKTOP, INPUT_LOGIN, INPUT_PASSWORD}; enum shutdown {SHUTDOWN_NO, SHUTDOWN_YES, SHUTDOWN_REBOOT}; -int main (int argc, char **argv) +bool args(int argc, char** argv) +{ + char* arg; + + while (argc > 0) + { + arg = argv[argc - 1]; + + if (strcmp(arg, "-v") == 0 + || strcmp(arg, "--version") == 0) + { + printf("ly version %s\n", GIT_VERSION_STRING); + return false; + } + + --argc; + } + + return true; +} + +int main(int argc, char** argv) { struct desktop desktop; struct input login; @@ -23,6 +45,11 @@ int main (int argc, char **argv) enum err error = OK; enum err status; + if (!args(argc, argv)) + { + return 0; + } + void* input_structs[3] = { (void*) &desktop,