From b0c5da3cc1fcfcf3a20fa0c184f721d386945b6a Mon Sep 17 00:00:00 2001 From: Reimu NotMoe Date: Fri, 23 Aug 2024 04:45:56 +0800 Subject: [PATCH] Revert "Merge pull request #238 from Paiusco/add-version-flag" This reverts commit b29a08c7e50662747b026bf748cc508815c58edc, reversing changes made to 94fe670b5ea9d71cc33031defa7d454517fa6725. --- Client/ydotool.c | 43 +++++-------------------------------------- Daemon/ydotoold.c | 1 - 2 files changed, 5 insertions(+), 39 deletions(-) diff --git a/Client/ydotool.c b/Client/ydotool.c index 6665a80..7c1992b 100644 --- a/Client/ydotool.c +++ b/Client/ydotool.c @@ -38,14 +38,9 @@ #include #include -#include #include -#ifndef VERSION -#define VERSION "unknown" -#endif - struct tool_def { char name[16]; void *ptr; @@ -86,10 +81,7 @@ static const struct tool_def tool_list[] = { }; static void show_help() { - puts("Usage: ydotool [OPTION] \n" - "Options:\n" - " -h, --help Display this help and exit\n" - " -V, --version Show version information\n" + puts("Usage: ydotool \n" "Available commands:"); int tool_count = sizeof(tool_list) / sizeof(struct tool_def); @@ -101,11 +93,6 @@ static void show_help() { puts("Use environment variable YDOTOOL_SOCKET to specify daemon socket."); } -static void show_version() { - puts("ydotool version(or hash): "); - puts(VERSION); -} - void uinput_emit(uint16_t type, uint16_t code, int32_t val, bool syn_report) { struct input_event ie = { .type = type, @@ -125,29 +112,9 @@ void uinput_emit(uint16_t type, uint16_t code, int32_t val, bool syn_report) { } int main(int argc, char **argv) { - - static struct option long_options[] = { - {"help", no_argument, 0, 'h'}, - {"version", no_argument, 0, 'V'}, - }; - - int opt = getopt_long(argc, argv, "hV", long_options, NULL); - if (opt != -1) - { - switch (opt) { - case 'h': - show_help(); - exit(0); - - case 'V': - show_version(); - exit(0); - - default: - puts("Not a valid option\n"); - show_help(); - exit(1); - } + if (argc < 2 || strncmp(argv[1], "-h", 2) == 0 || strncmp(argv[1], "--h", 3) == 0 || strcmp(argv[1], "help") == 0) { + show_help(); + return 0; } int (*tool_main)(int argc, char **argv) = NULL; @@ -162,7 +129,7 @@ int main(int argc, char **argv) { if (!tool_main) { printf("ydotool: Unknown command: %s\n" - "Run 'ydotool --help' if you want a command list\n", argv[1]); + "Run 'ydotool help' if you want a command list\n", argv[1]); return 1; } diff --git a/Daemon/ydotoold.c b/Daemon/ydotoold.c index ff2d05b..de09904 100644 --- a/Daemon/ydotoold.c +++ b/Daemon/ydotoold.c @@ -92,7 +92,6 @@ static void show_help() { } static void show_version() { - puts("ydotoold version(or hash): "); puts(VERSION); }