mirror of https://github.com/fairyglade/ly.git
added version flag support
This commit is contained in:
parent
b0ce2ed635
commit
4dee666dcf
1
makefile
1
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)
|
||||
|
|
|
|||
29
src/main.c
29
src/main.c
|
|
@ -8,11 +8,33 @@
|
|||
#include "util.h"
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue